1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-15 08:10:17 +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:22:14 +00:00
parent 189171c5bb
commit 4a19ed0452
4 changed files with 11 additions and 2 deletions

View file

@ -319,7 +319,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;
}
@ -365,7 +365,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 *