Re: [ng-spice] History and command completion


To ng-spice@ieee.ing.uniroma1.it
From Al Davis <aldavis@ieee.org>
Date Mon, 13 Nov 2000 16:27:01 -0800
Delivered-To mailing list ng-spice@ieee.ing.uniroma1.it
In-Reply-To <00111103295502.07959@hobbes >
Mailing-List contact ng-spice-help@ieee.ing.uniroma1.it; run by ezmlm
References <GDDFCNDEIDKDIAAA@hotbot.com > <3A0D18CE.F7CC7039@uci.agh.edu.pl > <00111103295502.07959@hobbes >
Reply-To ng-spice@ieee.ing.uniroma1.it

On Sat, 11 Nov 2000, Al Davis wrote:
> void *calloc(size_t nmemb, size_t size)
> {
>    void* t = malloc(nmemb * size);
>    memset(t, 0, nmemb * size);
>    return t;
> }

I made a mistake.  That one could crash.  Try this one:

void *calloc(size_t nmemb, size_t size)
{
   void* t = malloc(nmemb * size);
   if (t) {
      memset(t, 0, nmemb * size);
   }
   return t;
}

I made this up, but I believe that actual code in most C libraries is
the same or equivalent.

If you are replacing malloc, you probably need to replace calloc, too,
because the library calloc will probably call its own malloc even if
you supply one externally.  They are usually coded in the same source
module, so are usually linked together.


Partial thread listing: