1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 01:00:20 +02:00

(scm_gc_malloc): Return NULL if requested size is 0.

(scm_gc_free): Don't call `free' if mem is NULL.
This commit is contained in:
Neil Jerram 2008-02-06 22:16:35 +00:00
parent 136cddb3e4
commit c14bb7ad22
4 changed files with 11 additions and 2 deletions

View file

@ -317,7 +317,7 @@ scm_gc_malloc (size_t size, const char *what)
to write it the program is killed with signal 11. --hwn
*/
void *ptr = scm_malloc (size);
void *ptr = size ? scm_malloc (size) : NULL;
scm_gc_register_collectable_memory (ptr, size, what);
return ptr;
}
@ -363,7 +363,8 @@ void
scm_gc_free (void *mem, size_t size, const char *what)
{
scm_gc_unregister_collectable_memory (mem, size, what);
free (mem);
if (mem)
free (mem);
}
char *