Re: [ng-spice] History and command completion
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:
- Re: [ng-spice] History and command completion, (continued)
GLAO S. Dezai
ng-spice site.,
GLAO S. Dezai
Re: [ng-spice] Glao's patches,
GLAO S. Dezai