From 58ecbd5edeb2357c313db75bc49d45981a2061b7 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 6 Nov 2010 06:44:11 -0500 Subject: [PATCH 1/7] wrapper: move xmmap() to sha1_file.c wrapper.o depends on sha1_file.o for a number of reasons. One is release_pack_memory(). xmmap function calls mmap, discarding unused pack windows when necessary to relieve memory pressure. Simple git programs using wrapper.o as a friendly libc do not need this functionality. So move xmmap to sha1_file.o, where release_pack_memory() is. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- sha1_file.c | 15 +++++++++++++++ wrapper.c | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sha1_file.c b/sha1_file.c index 0cd9435619..8e299ae85c 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -576,6 +576,21 @@ void release_pack_memory(size_t need, int fd) ; /* nothing */ } +void *xmmap(void *start, size_t length, + int prot, int flags, int fd, off_t offset) +{ + void *ret = mmap(start, length, prot, flags, fd, offset); + if (ret == MAP_FAILED) { + if (!length) + return NULL; + release_pack_memory(length, fd); + ret = mmap(start, length, prot, flags, fd, offset); + if (ret == MAP_FAILED) + die_errno("Out of memory? mmap failed"); + } + return ret; +} + void close_pack_windows(struct packed_git *p) { while (p->windows) { diff --git a/wrapper.c b/wrapper.c index fd8ead33ed..3195ef32b7 100644 --- a/wrapper.c +++ b/wrapper.c @@ -108,21 +108,6 @@ void *xcalloc(size_t nmemb, size_t size) return ret; } -void *xmmap(void *start, size_t length, - int prot, int flags, int fd, off_t offset) -{ - void *ret = mmap(start, length, prot, flags, fd, offset); - if (ret == MAP_FAILED) { - if (!length) - return NULL; - release_pack_memory(length, fd); - ret = mmap(start, length, prot, flags, fd, offset); - if (ret == MAP_FAILED) - die_errno("Out of memory? mmap failed"); - } - return ret; -} - /* * xread() is the same a read(), but it automatically restarts read() * operations with a recoverable error (EAGAIN and EINTR). xread() From 463db9b104b5db7d574ce4c5ede8caaa6d02ff4c Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 6 Nov 2010 06:45:38 -0500 Subject: [PATCH 2/7] wrapper: move odb_* to environment.c The odb_mkstemp and odb_pack_keep functions open files under the $GIT_OBJECT_DIRECTORY directory. This requires access to the git configuration which very simple programs do not need. Move these functions to environment.o, closer to their dependencies. This should make it easier for programs to link to wrapper.o without linking to environment.o. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- environment.c | 37 +++++++++++++++++++++++++++++++++++++ git-compat-util.h | 1 + wrapper.c | 37 ------------------------------------- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/environment.c b/environment.c index de5581fe51..95777f4c7f 100644 --- a/environment.c +++ b/environment.c @@ -171,6 +171,43 @@ char *get_object_directory(void) return git_object_dir; } +int odb_mkstemp(char *template, size_t limit, const char *pattern) +{ + int fd; + /* + * we let the umask do its job, don't try to be more + * restrictive except to remove write permission. + */ + int mode = 0444; + snprintf(template, limit, "%s/%s", + get_object_directory(), pattern); + fd = git_mkstemp_mode(template, mode); + if (0 <= fd) + return fd; + + /* slow path */ + /* some mkstemp implementations erase template on failure */ + snprintf(template, limit, "%s/%s", + get_object_directory(), pattern); + safe_create_leading_directories(template); + return xmkstemp_mode(template, mode); +} + +int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1) +{ + int fd; + + snprintf(name, namesz, "%s/pack/pack-%s.keep", + get_object_directory(), sha1_to_hex(sha1)); + fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600); + if (0 <= fd) + return fd; + + /* slow path */ + safe_create_leading_directories(name); + return open(name, O_RDWR|O_CREAT|O_EXCL, 0600); +} + char *get_index_file(void) { if (!git_index_file) diff --git a/git-compat-util.h b/git-compat-util.h index 2af8d3edbe..029162eccc 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -404,6 +404,7 @@ extern ssize_t xwrite(int fd, const void *buf, size_t len); extern int xdup(int fd); extern FILE *xfdopen(int fd, const char *mode); extern int xmkstemp(char *template); +extern int xmkstemp_mode(char *template, int mode); extern int odb_mkstemp(char *template, size_t limit, const char *pattern); extern int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1); diff --git a/wrapper.c b/wrapper.c index 3195ef32b7..e67b70a108 100644 --- a/wrapper.c +++ b/wrapper.c @@ -274,43 +274,6 @@ int git_inflate(z_streamp strm, int flush) return ret; } -int odb_mkstemp(char *template, size_t limit, const char *pattern) -{ - int fd; - /* - * we let the umask do its job, don't try to be more - * restrictive except to remove write permission. - */ - int mode = 0444; - snprintf(template, limit, "%s/%s", - get_object_directory(), pattern); - fd = git_mkstemp_mode(template, mode); - if (0 <= fd) - return fd; - - /* slow path */ - /* some mkstemp implementations erase template on failure */ - snprintf(template, limit, "%s/%s", - get_object_directory(), pattern); - safe_create_leading_directories(template); - return xmkstemp_mode(template, mode); -} - -int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1) -{ - int fd; - - snprintf(name, namesz, "%s/pack/pack-%s.keep", - get_object_directory(), sha1_to_hex(sha1)); - fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600); - if (0 <= fd) - return fd; - - /* slow path */ - safe_create_leading_directories(name); - return open(name, O_RDWR|O_CREAT|O_EXCL, 0600); -} - static int warn_if_unremovable(const char *op, const char *file, int rc) { if (rc < 0) { From 33f239365cce2682a1faac0d5670d684aa1981ad Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 6 Nov 2010 06:46:31 -0500 Subject: [PATCH 3/7] path helpers: move git_mkstemp* to wrapper.c git_mkstemp_mode and related functions do not require access to specialized git machinery, unlike some other functions from path.c (like set_shared_perm()). Move them to wrapper.c where the wrapper xmkstemp_mode is defined. This eliminates a dependency of wrapper.o on environment.o via path.o. With typical linkers (e.g., gcc), that dependency makes programs that use functions from wrapper.o and not environment.o or path.o larger than they need to be. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- path.c | 113 ------------------------------------------------------ wrapper.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 113 deletions(-) diff --git a/path.c b/path.c index a2c9d1e24a..8951333cb8 100644 --- a/path.c +++ b/path.c @@ -161,119 +161,6 @@ char *git_path_submodule(const char *path, const char *fmt, ...) return cleanup_path(pathname); } -/* git_mkstemp() - create tmp file honoring TMPDIR variable */ -int git_mkstemp(char *path, size_t len, const char *template) -{ - const char *tmp; - size_t n; - - tmp = getenv("TMPDIR"); - if (!tmp) - tmp = "/tmp"; - n = snprintf(path, len, "%s/%s", tmp, template); - if (len <= n) { - errno = ENAMETOOLONG; - return -1; - } - return mkstemp(path); -} - -/* git_mkstemps() - create tmp file with suffix honoring TMPDIR variable. */ -int git_mkstemps(char *path, size_t len, const char *template, int suffix_len) -{ - const char *tmp; - size_t n; - - tmp = getenv("TMPDIR"); - if (!tmp) - tmp = "/tmp"; - n = snprintf(path, len, "%s/%s", tmp, template); - if (len <= n) { - errno = ENAMETOOLONG; - return -1; - } - return mkstemps(path, suffix_len); -} - -/* Adapted from libiberty's mkstemp.c. */ - -#undef TMP_MAX -#define TMP_MAX 16384 - -int git_mkstemps_mode(char *pattern, int suffix_len, int mode) -{ - static const char letters[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; - static const int num_letters = 62; - uint64_t value; - struct timeval tv; - char *template; - size_t len; - int fd, count; - - len = strlen(pattern); - - if (len < 6 + suffix_len) { - errno = EINVAL; - return -1; - } - - if (strncmp(&pattern[len - 6 - suffix_len], "XXXXXX", 6)) { - errno = EINVAL; - return -1; - } - - /* - * Replace pattern's XXXXXX characters with randomness. - * Try TMP_MAX different filenames. - */ - gettimeofday(&tv, NULL); - value = ((size_t)(tv.tv_usec << 16)) ^ tv.tv_sec ^ getpid(); - template = &pattern[len - 6 - suffix_len]; - for (count = 0; count < TMP_MAX; ++count) { - uint64_t v = value; - /* Fill in the random bits. */ - template[0] = letters[v % num_letters]; v /= num_letters; - template[1] = letters[v % num_letters]; v /= num_letters; - template[2] = letters[v % num_letters]; v /= num_letters; - template[3] = letters[v % num_letters]; v /= num_letters; - template[4] = letters[v % num_letters]; v /= num_letters; - template[5] = letters[v % num_letters]; v /= num_letters; - - fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode); - if (fd > 0) - return fd; - /* - * Fatal error (EPERM, ENOSPC etc). - * It doesn't make sense to loop. - */ - if (errno != EEXIST) - break; - /* - * This is a random value. It is only necessary that - * the next TMP_MAX values generated by adding 7777 to - * VALUE are different with (module 2^32). - */ - value += 7777; - } - /* We return the null string if we can't find a unique file name. */ - pattern[0] = '\0'; - return -1; -} - -int git_mkstemp_mode(char *pattern, int mode) -{ - /* mkstemp is just mkstemps with no suffix */ - return git_mkstemps_mode(pattern, 0, mode); -} - -int gitmkstemps(char *pattern, int suffix_len) -{ - return git_mkstemps_mode(pattern, suffix_len, 0600); -} - int validate_headref(const char *path) { struct stat st; diff --git a/wrapper.c b/wrapper.c index e67b70a108..b3efefb539 100644 --- a/wrapper.c +++ b/wrapper.c @@ -204,6 +204,119 @@ int xmkstemp(char *template) return fd; } +/* git_mkstemp() - create tmp file honoring TMPDIR variable */ +int git_mkstemp(char *path, size_t len, const char *template) +{ + const char *tmp; + size_t n; + + tmp = getenv("TMPDIR"); + if (!tmp) + tmp = "/tmp"; + n = snprintf(path, len, "%s/%s", tmp, template); + if (len <= n) { + errno = ENAMETOOLONG; + return -1; + } + return mkstemp(path); +} + +/* git_mkstemps() - create tmp file with suffix honoring TMPDIR variable. */ +int git_mkstemps(char *path, size_t len, const char *template, int suffix_len) +{ + const char *tmp; + size_t n; + + tmp = getenv("TMPDIR"); + if (!tmp) + tmp = "/tmp"; + n = snprintf(path, len, "%s/%s", tmp, template); + if (len <= n) { + errno = ENAMETOOLONG; + return -1; + } + return mkstemps(path, suffix_len); +} + +/* Adapted from libiberty's mkstemp.c. */ + +#undef TMP_MAX +#define TMP_MAX 16384 + +int git_mkstemps_mode(char *pattern, int suffix_len, int mode) +{ + static const char letters[] = + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"; + static const int num_letters = 62; + uint64_t value; + struct timeval tv; + char *template; + size_t len; + int fd, count; + + len = strlen(pattern); + + if (len < 6 + suffix_len) { + errno = EINVAL; + return -1; + } + + if (strncmp(&pattern[len - 6 - suffix_len], "XXXXXX", 6)) { + errno = EINVAL; + return -1; + } + + /* + * Replace pattern's XXXXXX characters with randomness. + * Try TMP_MAX different filenames. + */ + gettimeofday(&tv, NULL); + value = ((size_t)(tv.tv_usec << 16)) ^ tv.tv_sec ^ getpid(); + template = &pattern[len - 6 - suffix_len]; + for (count = 0; count < TMP_MAX; ++count) { + uint64_t v = value; + /* Fill in the random bits. */ + template[0] = letters[v % num_letters]; v /= num_letters; + template[1] = letters[v % num_letters]; v /= num_letters; + template[2] = letters[v % num_letters]; v /= num_letters; + template[3] = letters[v % num_letters]; v /= num_letters; + template[4] = letters[v % num_letters]; v /= num_letters; + template[5] = letters[v % num_letters]; v /= num_letters; + + fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode); + if (fd > 0) + return fd; + /* + * Fatal error (EPERM, ENOSPC etc). + * It doesn't make sense to loop. + */ + if (errno != EEXIST) + break; + /* + * This is a random value. It is only necessary that + * the next TMP_MAX values generated by adding 7777 to + * VALUE are different with (module 2^32). + */ + value += 7777; + } + /* We return the null string if we can't find a unique file name. */ + pattern[0] = '\0'; + return -1; +} + +int git_mkstemp_mode(char *pattern, int mode) +{ + /* mkstemp is just mkstemps with no suffix */ + return git_mkstemps_mode(pattern, 0, mode); +} + +int gitmkstemps(char *pattern, int suffix_len) +{ + return git_mkstemps_mode(pattern, suffix_len, 0600); +} + int xmkstemp_mode(char *template, int mode) { int fd; From 6bab74e7fb89b7427e5ef24b48a07fe9450c40e7 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 6 Nov 2010 06:46:52 -0500 Subject: [PATCH 4/7] strbuf: move strbuf_branchname to sha1_name.c strbuf_branchname is a thin wrapper around interpret_branch_name from sha1_name.o. Most strbuf.o users do not need it. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- sha1_name.c | 18 ++++++++++++++++++ strbuf.c | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 484081de82..32522c0fe5 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -934,6 +934,24 @@ int interpret_branch_name(const char *name, struct strbuf *buf) return len; } +int strbuf_branchname(struct strbuf *sb, const char *name) +{ + int len = strlen(name); + if (interpret_branch_name(name, sb) == len) + return 0; + strbuf_add(sb, name, len); + return len; +} + +int strbuf_check_branch_ref(struct strbuf *sb, const char *name) +{ + strbuf_branchname(sb, name); + if (name[0] == '-') + return CHECK_REF_FORMAT_ERROR; + strbuf_splice(sb, 0, 0, "refs/heads/", 11); + return check_ref_format(sb->buf); +} + /* * This is like "get_sha1_basic()", except it allows "sha1 expressions", * notably "xyz^" for "parent of xyz" diff --git a/strbuf.c b/strbuf.c index 65b4cf4343..9b3c4457f2 100644 --- a/strbuf.c +++ b/strbuf.c @@ -386,21 +386,3 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) return len; } - -int strbuf_branchname(struct strbuf *sb, const char *name) -{ - int len = strlen(name); - if (interpret_branch_name(name, sb) == len) - return 0; - strbuf_add(sb, name, len); - return len; -} - -int strbuf_check_branch_ref(struct strbuf *sb, const char *name) -{ - strbuf_branchname(sb, name); - if (name[0] == '-') - return CHECK_REF_FORMAT_ERROR; - strbuf_splice(sb, 0, 0, "refs/heads/", 11); - return check_ref_format(sb->buf); -} From b0613ce0f9ef3fd111f8c75b84ddd12f9f04fc87 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 6 Nov 2010 06:47:34 -0500 Subject: [PATCH 5/7] wrapper: give zlib wrappers their own translation unit Programs using xmalloc() but not git_inflate() require -lz on the linker command line because git_inflate() is in the same translation unit as xmalloc(). Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Makefile | 1 + wrapper.c | 60 ------------------------------------------------------ zlib.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 60 deletions(-) create mode 100644 zlib.c diff --git a/Makefile b/Makefile index 1f1ce04edf..a8ba33635d 100644 --- a/Makefile +++ b/Makefile @@ -662,6 +662,7 @@ LIB_OBJS += write_or_die.o LIB_OBJS += ws.o LIB_OBJS += wt-status.o LIB_OBJS += xdiff-interface.o +LIB_OBJS += zlib.o BUILTIN_OBJS += builtin/add.o BUILTIN_OBJS += builtin/annotate.o diff --git a/wrapper.c b/wrapper.c index b3efefb539..185dfbcc46 100644 --- a/wrapper.c +++ b/wrapper.c @@ -327,66 +327,6 @@ int xmkstemp_mode(char *template, int mode) return fd; } -/* - * zlib wrappers to make sure we don't silently miss errors - * at init time. - */ -void git_inflate_init(z_streamp strm) -{ - const char *err; - - switch (inflateInit(strm)) { - case Z_OK: - return; - - case Z_MEM_ERROR: - err = "out of memory"; - break; - case Z_VERSION_ERROR: - err = "wrong version"; - break; - default: - err = "error"; - } - die("inflateInit: %s (%s)", err, strm->msg ? strm->msg : "no message"); -} - -void git_inflate_end(z_streamp strm) -{ - if (inflateEnd(strm) != Z_OK) - error("inflateEnd: %s", strm->msg ? strm->msg : "failed"); -} - -int git_inflate(z_streamp strm, int flush) -{ - int ret = inflate(strm, flush); - const char *err; - - switch (ret) { - /* Out of memory is fatal. */ - case Z_MEM_ERROR: - die("inflate: out of memory"); - - /* Data corruption errors: we may want to recover from them (fsck) */ - case Z_NEED_DICT: - err = "needs dictionary"; break; - case Z_DATA_ERROR: - err = "data stream error"; break; - case Z_STREAM_ERROR: - err = "stream consistency error"; break; - default: - err = "unknown error"; break; - - /* Z_BUF_ERROR: normal, needs more space in the output buffer */ - case Z_BUF_ERROR: - case Z_OK: - case Z_STREAM_END: - return ret; - } - error("inflate: %s (%s)", err, strm->msg ? strm->msg : "no message"); - return ret; -} - static int warn_if_unremovable(const char *op, const char *file, int rc) { if (rc < 0) { diff --git a/zlib.c b/zlib.c new file mode 100644 index 0000000000..c4d58da4e9 --- /dev/null +++ b/zlib.c @@ -0,0 +1,61 @@ +/* + * zlib wrappers to make sure we don't silently miss errors + * at init time. + */ +#include "cache.h" + +void git_inflate_init(z_streamp strm) +{ + const char *err; + + switch (inflateInit(strm)) { + case Z_OK: + return; + + case Z_MEM_ERROR: + err = "out of memory"; + break; + case Z_VERSION_ERROR: + err = "wrong version"; + break; + default: + err = "error"; + } + die("inflateInit: %s (%s)", err, strm->msg ? strm->msg : "no message"); +} + +void git_inflate_end(z_streamp strm) +{ + if (inflateEnd(strm) != Z_OK) + error("inflateEnd: %s", strm->msg ? strm->msg : "failed"); +} + +int git_inflate(z_streamp strm, int flush) +{ + int ret = inflate(strm, flush); + const char *err; + + switch (ret) { + /* Out of memory is fatal. */ + case Z_MEM_ERROR: + die("inflate: out of memory"); + + /* Data corruption errors: we may want to recover from them (fsck) */ + case Z_NEED_DICT: + err = "needs dictionary"; break; + case Z_DATA_ERROR: + err = "data stream error"; break; + case Z_STREAM_ERROR: + err = "stream consistency error"; break; + default: + err = "unknown error"; break; + + /* Z_BUF_ERROR: normal, needs more space in the output buffer */ + case Z_BUF_ERROR: + case Z_OK: + case Z_STREAM_END: + return ret; + } + error("inflate: %s (%s)", err, strm->msg ? strm->msg : "no message"); + return ret; +} From bc9b21755ebf82d06a60886947bdbd8d0f14baf1 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 6 Nov 2010 06:47:57 -0500 Subject: [PATCH 6/7] pack-objects: mark file-local variable static old_try_to_free_routine is not meant for use from other files. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/pack-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index f8eba53c82..7471c92b93 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1529,7 +1529,7 @@ static void try_to_free_from_threads(size_t size) read_unlock(); } -try_to_free_t old_try_to_free_routine; +static try_to_free_t old_try_to_free_routine; /* * The main thread waits on the condition that (at least) one of the workers From e0500293852910c2f44fce61e7eb856adbc20d8a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 6 Nov 2010 14:00:38 -0500 Subject: [PATCH 7/7] Remove pack file handling dependency from wrapper.o MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As v1.7.0-rc0~43 (slim down "git show-index", 2010-01-21) explains, use of xmalloc() brings in a dependency on zlib, the sha1 lib, and the rest of git's object file access machinery via try_to_free_pack_memory. That is overkill when xmalloc is just being used as a convenience wrapper to exit when no memory is available. So defer setting try_to_free_pack_memory as try_to_free_routine until the first packfile is opened in add_packed_git(). After this change, a simple program using xmalloc() and no other functions will not pull in any code from libgit.a aside from wrapper.o and usage.o. Improved-by: René Scharfe Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- sha1_file.c | 11 +++++++++++ wrapper.c | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sha1_file.c b/sha1_file.c index 8e299ae85c..e0d2496bcd 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -818,11 +818,22 @@ static struct packed_git *alloc_packed_git(int extra) return p; } +static void try_to_free_pack_memory(size_t size) +{ + release_pack_memory(size, -1); +} + struct packed_git *add_packed_git(const char *path, int path_len, int local) { + static int have_set_try_to_free_routine; struct stat st; struct packed_git *p = alloc_packed_git(path_len + 2); + if (!have_set_try_to_free_routine) { + have_set_try_to_free_routine = 1; + set_try_to_free_routine(try_to_free_pack_memory); + } + /* * Make sure a corresponding .pack file exists and that * the index looks sane. diff --git a/wrapper.c b/wrapper.c index 185dfbcc46..4c1639f153 100644 --- a/wrapper.c +++ b/wrapper.c @@ -3,12 +3,11 @@ */ #include "cache.h" -static void try_to_free_builtin(size_t size) +static void do_nothing(size_t size) { - release_pack_memory(size, -1); } -static void (*try_to_free_routine)(size_t size) = try_to_free_builtin; +static void (*try_to_free_routine)(size_t size) = do_nothing; try_to_free_t set_try_to_free_routine(try_to_free_t routine) {