void acl_default_free(const char *filename, int line, void *ptr) { const char *myname = "acl_default_free"; MBLOCK *real_ptr; size_t len; const char *pname = NULL; if (filename && *filename) SET_FILE(pname, filename); else pname = __FILENAME_UNKNOWN; if (ptr == NULL) { acl_msg_error("%s(%d)->%s: ptr null", pname, line, myname); return; } # ifndef NO_SHARED_EMPTY_STRINGS if (ptr != empty_string) { # endif CHECK_IN_PTR(ptr, real_ptr, len, pname, line); /* memset((char *) real_ptr, FILLER, SPACE_FOR(len)); */ #ifdef _USE_GLIB g_free(real_ptr); #else free((char *) real_ptr); #endif # ifndef NO_SHARED_EMPTY_STRINGS } # endif }
char *myrealloc(char *ptr, ssize_t len) { MBLOCK *real_ptr; ssize_t old_len; #ifndef NO_SHARED_EMPTY_STRINGS if (ptr == empty_string) return (mymalloc(len)); #endif /* * Note: for safety reasons the request length is a signed type. This * allows us to catch integer overflow problems that weren't already * caught up-stream. */ if (len < 1) msg_panic("myrealloc: requested length %ld", (long) len); #ifdef MYMALLOC_FUZZ len += MYMALLOC_FUZZ; #endif CHECK_IN_PTR(ptr, real_ptr, old_len, "myrealloc"); if ((real_ptr = (MBLOCK *) realloc((char *) real_ptr, SPACE_FOR(len))) == 0) msg_fatal("myrealloc: insufficient memory for %ld bytes: %m", (long) len); CHECK_OUT_PTR(ptr, real_ptr, len); if (len > old_len) memset(ptr + old_len, FILLER, len - old_len); return (ptr); }
void *acl_default_realloc(const char *filename, int line, void *ptr, size_t len) { const char *myname = "acl_default_realloc"; MBLOCK *real_ptr; size_t old_len, new_len; const char *pname = NULL; if (filename && *filename) SET_FILE(pname, filename); else pname = __FILENAME_UNKNOWN; #ifndef NO_SHARED_EMPTY_STRINGS if (ptr == empty_string) return acl_default_malloc(pname, line, len); #endif if (len < 1) { acl_msg_warn("%s(%d)->%s: realloc: requested length %ld", pname, line, myname, (long) len); len = 128; } if (ptr == NULL) return acl_default_malloc(pname, line, len); CHECK_IN_PTR(ptr, real_ptr, old_len, pname, line); new_len = SPACE_FOR(len); if (new_len <= 0) acl_msg_fatal("%s(%d): new_len(%d) <= 0", myname, __LINE__, (int) new_len); else if (new_len >= __malloc_limit) { acl_msg_warn("%s(%d): new_len(%d) too large", myname, __LINE__, (int) new_len); } #ifdef _USE_GLIB if ((real_ptr = (MBLOCK *) g_realloc((char *) real_ptr, new_len)) == 0) acl_msg_fatal("%s(%d)->%s: realloc: insufficient memory: %s", pname, line, myname, strerror(errno)); #else if ((real_ptr = (MBLOCK *) realloc((char *) real_ptr, new_len)) == 0) acl_msg_fatal("%s(%d)->%s: realloc: insufficient memory: %s", pname, line, myname, strerror(errno)); #endif CHECK_OUT_PTR(ptr, real_ptr, len); #if 0 if (len > old_len) memset((char *) ptr + old_len, FILLER, len - old_len); #endif return ptr; }
void myfree(char *ptr) { MBLOCK *real_ptr; ssize_t len; #ifndef NO_SHARED_EMPTY_STRINGS if (ptr != empty_string) { #endif CHECK_IN_PTR(ptr, real_ptr, len, "myfree"); memset((char *) real_ptr, FILLER, SPACE_FOR(len)); free((char *) real_ptr); #ifndef NO_SHARED_EMPTY_STRINGS } #endif }