Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   Add resolved_path to alpm_filelist_t (http://www.linux-archive.org/archlinux-pacman-development/688541-add-resolved_path-alpm_filelist_t.html)

Allan McRae 07-29-2012 06:18 AM

Add resolved_path to alpm_filelist_t
 
Add an array to hold the resolved paths of the files in alpm_filelist_t.
When the file name and its resolved file name are identical, the pointer
to the original file name is used to avoid duplicate memory allocation.

Signed-off-by: Allan McRae <allan@archlinux.org>
---
lib/libalpm/alpm.h | 1 +
lib/libalpm/package.c | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 9aa6ac2..c341b17 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -213,6 +213,7 @@ typedef struct _alpm_file_t {
typedef struct _alpm_filelist_t {
size_t count;
alpm_file_t *files;
+ char **resolved_path;
} alpm_filelist_t;

/** Local package or package file backup entry */
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a4c3309..ab84329 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -540,6 +540,9 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
}
}
newpkg->files.count = pkg->files.count;
+ /* deliberately do not copy resolved_path as this is only used
+ * during conflict checking and the sorting of list does not readily
+ * allow keeping its efficient memory usage when copying */
}

/* internal */
@@ -590,9 +593,15 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
if(pkg->files.count) {
size_t i;
for(i = 0; i < pkg->files.count; i++) {
- free(pkg->files.files[i].name);
+ FREE(pkg->files.files[i].name);
}
free(pkg->files.files);
+ if(pkg->files.resolved_path) {
+ for(i = 0; i < pkg->files.count; i++) {
+ free(pkg->files.resolved_path[i]);
+ }
+ free(pkg->files.resolved_path);
+ }
}
alpm_list_free_inner(pkg->backup, (alpm_list_fn_free)_alpm_backup_free);
alpm_list_free(pkg->backup);
--
1.7.11.3


All times are GMT. The time now is 08:06 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.