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/conflict.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/libalpm/conflict.h') diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h index a846aace..41cee934 100644 --- a/lib/libalpm/conflict.h +++ b/lib/libalpm/conflict.h @@ -23,27 +23,28 @@ #include "db.h" #include "package.h" -#define CONFLICT_FILE_LEN 512 - struct __pmconflict_t { - char package1[PKG_NAME_LEN]; - char package2[PKG_NAME_LEN]; + char *package1; + char *package2; }; struct __pmfileconflict_t { - char target[PKG_NAME_LEN]; + char *target; pmfileconflicttype_t type; - char file[CONFLICT_FILE_LEN]; - char ctarget[PKG_NAME_LEN]; + char *file; + char *ctarget; }; pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2); +void _alpm_conflict_free(pmconflict_t *conflict); int _alpm_conflict_isin(pmconflict_t *needle, alpm_list_t *haystack); alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages); alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages); alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages); alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans, char *root); +void _alpm_fileconflict_free(pmfileconflict_t *conflict); + #endif /* _ALPM_CONFLICT_H */ /* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3-24-g4f1b