misc/alloc-monitor.c
void *realloc(void *ptr, size_t size) {
    void *ptr2;

    if (!exists(ptr))
        /* Code using realloc instead of malloc. */
        fprintf(stderr, "Alloc Monitor: Warning: attempt to realloc a pointer "
                "that does not appear to have been allocated (realloc "
                "abuse?).\n");
    else
        delete(ptr);

    if (!size)
        fprintf(stderr, "Alloc Monitor: Warning: attempt to free through "
                "realloc (realloc abuse?).\n");

    assert(real_realloc);
    ptr2 = real_realloc(ptr, size);
    if (!ptr2)
        fprintf(stderr, "Alloc Monitor: Warning: returning null pointer from "
                "realloc.\n");
    else
        add(ptr2);
    return ptr2;
}
/* Note the various conditions in the realloc wrapper to catch "abuses" of
 * realloc. By this I mean using realloc to malloc or free, which, while legal,
 * is a quick way to make your code untraceable. You may want to remove the
 * warnings if you really think you know what you're doing.
 */
Note the various conditions in the realloc wrapper to catch "abuses" of
realloc. By this I mean using realloc to malloc or free, which, while legal,
is a quick way to make your code untraceable. You may want to remove the
warnings if you really think you know what you're doing.
Note the various conditions in the realloc wrapper to catch " abuses " of realloc . By this I mean using realloc to malloc or free which while legal is a quick way to make your code untraceable . You may want to remove the warnings if you really think you know what you ' re doing .
void *realloc(void *ptr, size_t size) {
    void *ptr2;
    if (!exists(ptr))
        fprintf(stderr, "Alloc Monitor: Warning: attempt to realloc a pointer "
                "that does not appear to have been allocated (realloc "
                "abuse?).\n");
    else
        delete(ptr);
    if (!size)
        fprintf(stderr, "Alloc Monitor: Warning: attempt to free through "
                "realloc (realloc abuse?).\n");
    assert(real_realloc);
    ptr2 = real_realloc(ptr, size);
    if (!ptr2)
        fprintf(stderr, "Alloc Monitor: Warning: returning null pointer from "
                "realloc.\n");
    else
        add(ptr2);
    return ptr2;
}
void * realloc ( void * ptr , size_t size ) { void * ptr2 ; if ( ! exists ( ptr ) ) fprintf ( stderr , " " " " " \n " ) ; else delete ( ptr ) ; if ( ! size ) fprintf ( stderr , " " " \n " ) ; assert ( real_realloc ) ; ptr2 = real_realloc ( ptr , size ) ; if ( ! ptr2 ) fprintf ( stderr , " " " \n " ) ; else add ( ptr2 ) ; return ptr2 ; }
Note the various conditions in the realloc wrapper to catch "abuses" of
 realloc.
Note the various conditions in the realloc wrapper to catch " abuses " of realloc .
/* Code using realloc instead of malloc. */