freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "James K. Lowden" <jklowden AT freetds.org>
- To: TDS Development Group <freetds AT lists.ibiblio.org>
- Subject: [freetds] ENOMEM vs. errno
- Date: Thu, 6 Dec 2007 12:06:43 -0500
Hi Freddy,
I'm surprised by
$Id: dblib.c,v 1.312 2007/12/06 07:52:17 freddy77 Exp $
which replaces all
dbperror(dbproc, SYBEMEM, errno);
with
dbperror(dbproc, SYBEMEM, ENOMEM);
Was yesterday's discussion unclear?
If malloc fails, it must set errno to ENOMEM.
If malloc does not set errno to ENOMEM, the application should deal with
it.
db-lib's job in this case is only to convey what malloc(3) said. If
malloc returned NULL and didn't set errno to ENOMEM, that's not db-lib's
problem. That's for the application to settle with malloc(3). If the
application cannot rely on malloc to set errno, it has enough information
from SYBEMEM.
By hard-coding ENOMEM, you are hiding what actually happened, potentially
lying to the application.
Remember the application is written in C, too, and uses malloc all the
time. It knows how to recognize malloc failures. Win32 even has
_set_new_mode() to control how allocation errors are handled. I think it
sets errno by default. (The docs don't say so, but they do list ENOMEM as
one of the supported errno values.)
Would you kindly revert to 1.311?
Thanks. If I'm overlooking something, just say so.
Regards,
--jkl
-
[freetds] ENOMEM vs. errno,
James K. Lowden, 12/06/2007
-
Re: [freetds] ENOMEM vs. errno,
Frediano Ziglio, 12/06/2007
-
Re: [freetds] ENOMEM vs. errno,
Christos Zoulas, 12/06/2007
-
Re: [freetds] ENOMEM vs. errno,
Frediano Ziglio, 12/06/2007
- Re: [freetds] ENOMEM vs. errno, James K. Lowden, 12/07/2007
-
Re: [freetds] ENOMEM vs. errno,
Frediano Ziglio, 12/06/2007
-
Re: [freetds] ENOMEM vs. errno,
Christos Zoulas, 12/06/2007
-
Re: [freetds] ENOMEM vs. errno,
Frediano Ziglio, 12/06/2007
Archive powered by MHonArc 2.6.24.