Try to shrink returned buffer's allocation.

This commit is contained in:
Ryan C. Gordon 2009-07-08 17:47:05 -04:00
parent ff80fc8003
commit 43207273dd
1 changed files with 8 additions and 0 deletions

View File

@ -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 */