From ccc1c731529de16f6fa4064fd992a8f63d7cfc26 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 11 Jan 2008 00:01:58 -0600 Subject: Use dynamic string allocation in package structures This also affects all structures with static strings, such as depmiss, conflict, etc. This should help a lot with memory usage, and hopefully make things a bit more "idiot proof". Currently our pactest pass/fail rate is identical before and after this patch. This is not to say it is a perfect patch- I have yet to pull valgrind out. However, this should be quite safe to use in all situations from here on out, and we can start plugging the memleaks. Original-work-by: Aaron Griffin Signed-off-by: Dan McGee --- lib/libalpm/server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/libalpm/server.c') diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c index 4bccf3ca..c0622552 100644 --- a/lib/libalpm/server.c +++ b/lib/libalpm/server.c @@ -188,7 +188,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, char realfile[PATH_MAX]; char output[PATH_MAX]; char *fn = (char *)lp->data; - char pkgname[PKG_NAME_LEN]; + char *pkgname; fileurl = url_for_file(server, fn); if(!fileurl) { @@ -196,7 +196,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, } /* pass the raw filename for passing to the callback function */ - strncpy(pkgname, fn, PKG_NAME_LEN); + STRDUP(pkgname, fn, (void)0); _alpm_log(PM_LOG_DEBUG, "using '%s' for download progress\n", pkgname); snprintf(realfile, PATH_MAX, "%s%s", localpath, fn); @@ -403,6 +403,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, } chdir(cwd); } + FREE(pkgname); } if(alpm_list_count(complete) == alpm_list_count(files)) { -- cgit v1.2.3