Skip to content

Commit

Permalink
Try to shrink returned buffer's allocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 8, 2009
1 parent ff80fc8 commit 4320727
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/platform_unix.c
Expand Up @@ -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 */

Expand Down

0 comments on commit 4320727

Please sign in to comment.