Skip to Content.
Sympa Menu

freetds - Re: [freetds] malloc/errno portability considerations

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] malloc/errno portability considerations
  • Date: Wed, 5 Dec 2007 11:25:24 -0500

ZIGLIO, Frediano, VF-IT wrote:
> dbperror(NULL, SYBEMEM, errno);
>
> is not that portable. The reason is that not all malloc implementations
> set errno with ENOMEM. Why should replace the above line with
>
> dbperror(NULL, SYBEMEM, ENOMEM);

You're right, different OS's may set errno to ENOMEM or not. But the
purpose of the parameter is to pass the OS's error -- if any -- to the
error handler.

If the error handler wants to know the db-lib error, it has SYBEMEM. The
only way it can hope to report the underlying reason for the failure is by
examining os_error.

The application won't get the same answer on every OS. So what? It's not
FreeTDS's job to make all OS's behave the same way. In this case, it's
only job is to report what the OS said.

Which malloc were you thinking of, btw?

--jkl






Archive powered by MHonArc 2.6.24.

Top of Page