Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-29 20:14:10 -0500
committerDan McGee <dan@archlinux.org>2012-04-29 20:14:10 -0500
commit52a9a5240ac8dc9eef1fc68c1bf4290b76fe09ae (patch)
treee37ae79bdf8c9b9dbf1d21864e292fdce96f81ab /lib/libalpm/handle.c
parente0afd81d18fdc646bbf6d37a1627c0267176e167 (diff)
Move short-lived realpath buffers to the stack
There is little reason here to grab 4K from the heap only to return it a few lines later. Instead, just use the stack to hold the returned value saving ourselves the malloc/free cycle. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 2db27fbf..816162bd 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -333,7 +333,7 @@ alpm_errno_t _alpm_set_directory_option(const char *value,
char **storage, int must_exist)
{
struct stat st;
- char *real = NULL;
+ char real[PATH_MAX];
const char *path;
path = value;
@@ -344,9 +344,7 @@ alpm_errno_t _alpm_set_directory_option(const char *value,
if(stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
return ALPM_ERR_NOT_A_DIR;
}
- CALLOC(real, PATH_MAX, sizeof(char), return ALPM_ERR_MEMORY);
if(!realpath(path, real)) {
- free(real);
return ALPM_ERR_NOT_A_DIR;
}
path = real;
@@ -359,7 +357,6 @@ alpm_errno_t _alpm_set_directory_option(const char *value,
if(!*storage) {
return ALPM_ERR_MEMORY;
}
- free(real);
return 0;
}