current configure.in, 1.213, 1.214 miscutil.c, 1.83, 1.84

Fabian Keil <[email protected]> Mon, 29 May 2017 10:05:48 +0000
Newsgroups gmane.comp.web.privoxy.cvs
Message-ID <[email protected]>
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28376

Modified Files:
	configure.in miscutil.c 
Log Message:
Let zalloc() use calloc() if it's available

In some situations using calloc() can be faster than
malloc() + memset() and it should never be slower.

In the real world the impact of this change is not
expected to be noticeable.

Sponsored by: Robert Klemme


Index: configure.in
===================================================================
RCS file: /cvsroot/ijbswa/current/configure.in,v
retrieving revision 1.213
retrieving revision 1.214
diff -C2 -d -r1.213 -r1.214
*** configure.in	25 May 2017 11:17:11 -0000	1.213
--- configure.in	29 May 2017 10:05:46 -0000	1.214
***************
*** 783,786 ****
--- 783,787 ----
   arc4random \
   atexit \
+  calloc \
   getcwd \
   gethostbyaddr \

Index: miscutil.c
===================================================================
RCS file: /cvsroot/ijbswa/current/miscutil.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -C2 -d -r1.83 -r1.84
*** miscutil.c	4 May 2017 14:34:18 -0000	1.83
--- miscutil.c	29 May 2017 10:05:46 -0000	1.84
***************
*** 72,81 ****
   * Function    :  zalloc
   *
!  * Description :  Malloc some memory and set it to '\0'.
   *
   * Parameters  :
   *          1  :  size = Size of memory chunk to return.
   *
!  * Returns     :  Pointer to newly malloc'd memory chunk.
   *
   *********************************************************************/
--- 72,82 ----
   * Function    :  zalloc
   *
!  * Description :  Returns allocated memory that is initialized
!  *                with zeros.
   *
   * Parameters  :
   *          1  :  size = Size of memory chunk to return.
   *
!  * Returns     :  Pointer to newly alloc'd memory chunk.
   *
   *********************************************************************/
***************
*** 84,91 ****
--- 85,96 ----
     void * ret;
  
+ #ifdef HAVE_CALLOC
+    ret = calloc(1, size);
+ #else
     if ((ret = (void *)malloc(size)) != NULL)
     {
        memset(ret, 0, size);
     }
+ #endif
  
     return(ret);


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot