]> granicus.if.org Git - postgresql/commitdiff
Minor ecpg tweak: the return value of calloc() is guaranteed to be NULL
authorNeil Conway <neilc@samurai.com>
Thu, 30 Jun 2005 07:27:31 +0000 (07:27 +0000)
committerNeil Conway <neilc@samurai.com>
Thu, 30 Jun 2005 07:27:31 +0000 (07:27 +0000)
or zero-filled; therefore zero-filling it via memset() is pointless.
(I think setting `errno' is probably a waste of cycles as well, but I
haven't changed that.)

src/interfaces/ecpg/pgtypeslib/common.c

index d4b40098089b702461682b38f5639b1df1610cf6..903013a2e3a15afc9d9b43b79d314c2898daf72e 100644 (file)
@@ -2,18 +2,14 @@
 
 #include "extern.h"
 
+/* Return value is zero-filled. */
 char *
 pgtypes_alloc(long size)
 {
        char       *new = (char *) calloc(1L, size);
 
        if (!new)
-       {
                errno = ENOMEM;
-               return NULL;
-       }
-
-       memset(new, '\0', size);
        return (new);
 }