alloc functions may take 0 for the size
This commit is contained in:
parent
c85e07b7ee
commit
9495e9bf5c
6
src/gc.c
6
src/gc.c
|
@ -90,7 +90,7 @@ pic_alloc(pic_state *pic, size_t size)
|
|||
void *ptr;
|
||||
|
||||
ptr = malloc(size);
|
||||
if (ptr == NULL) {
|
||||
if (ptr == NULL && size > 0) {
|
||||
pic_abort(pic, "memory exhausted");
|
||||
}
|
||||
return ptr;
|
||||
|
@ -100,7 +100,7 @@ void *
|
|||
pic_realloc(pic_state *pic, void *ptr, size_t size)
|
||||
{
|
||||
ptr = realloc(ptr, size);
|
||||
if (ptr == NULL) {
|
||||
if (ptr == NULL && size > 0) {
|
||||
pic_abort(pic, "memory exhausted");
|
||||
}
|
||||
return ptr;
|
||||
|
@ -112,7 +112,7 @@ pic_calloc(pic_state *pic, size_t count, size_t size)
|
|||
void *ptr;
|
||||
|
||||
ptr = calloc(count ,size);
|
||||
if (ptr == NULL) {
|
||||
if (ptr == NULL && size > 0) {
|
||||
pic_abort(pic, "memory exhausted");
|
||||
}
|
||||
return ptr;
|
||||
|
|
Loading…
Reference in New Issue