if (p == 0) {
return GC_debug_malloc(lb, OPT_RA s, i);
}
+ if (0 == lb) /* and p != NULL */ {
+ GC_debug_free(p);
+ return NULL;
+ }
+
# ifdef GC_ADD_CALLER
if (s == NULL) {
GC_caller_func_offset(ra, &s, &i);
void *ret;
latestsize=new_size_in_bytes;
ret=GC_realloc(old_object,new_size_in_bytes);
- if(ret==NULL && GC_AMIGA_MEMF==(MEMF_FAST | MEMF_CLEAR)){
+ if(ret==NULL && new_size_in_bytes != 0
+ && GC_AMIGA_MEMF==(MEMF_FAST | MEMF_CLEAR)){
/* Out of fast-mem. */
#ifdef GC_AMIGA_GC
if(!GC_dont_gc){
}
#endif
}
- if(ret==NULL){
+ if(ret==NULL && new_size_in_bytes != 0){
WARN("Out of Memory! Returning NIL!\n", 0);
}
#ifdef GC_AMIGA_PRINTSTATS
/* The resulting object has the same kind as the original. */
/* If the argument is stubborn, the result will have changes enabled. */
/* It is an error to have changes enabled for the original object. */
-/* Follows ANSI conventions for NULL old_object. */
+/* It does not change the content of the object from its beginning to */
+/* the minimum of old size and new_size_in_bytes; the content above in */
+/* case of object size growth is initialized to zero (not guaranteed */
+/* for atomic object type). The function follows ANSI conventions for */
+/* NULL old_object (i.e., equivalent to GC_malloc regardless of new */
+/* size). If new size is zero (and old_object is non-NULL) then the */
+/* call is equivalent to GC_free (and NULL is returned). If old_object */
+/* is non-NULL, it must have been returned by an earlier call to */
+/* GC_malloc* or GC_realloc. In case of the allocation failure, the */
+/* memory pointed by old_object is untouched (and not freed). */
+/* If the returned pointer is not the same as old_object and both of */
+/* them are non-NULL then old_object is freed. Returns either NULL (in */
+/* case of the allocation failure or zero new size) or pointer to the */
+/* allocated memory. */
GC_API void * GC_CALL GC_realloc(void * /* old_object */,
size_t /* new_size_in_bytes */)
/* 'realloc' attr */ GC_ATTR_ALLOC_SIZE(2);