From 43207273dd73231ff75e8712726e736630ebd929 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 8 Jul 2009 17:47:05 -0400 Subject: [PATCH] Try to shrink returned buffer's allocation. --- src/platform_unix.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/platform_unix.c b/src/platform_unix.c index b575982..2dbd323 100644 --- a/src/platform_unix.c +++ b/src/platform_unix.c @@ -261,6 +261,14 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0) allocator.Free(envr); } /* if */ + if (retval != NULL) + { + /* try to shrink buffer... */ + char *ptr = (char *) allocator.Realloc(retval, strlen(retval) + 1); + if (ptr != NULL) + retval = ptr; /* oh well if it failed. */ + } /* if */ + return(retval); } /* __PHYSFS_platformCalcBaseDir */