summaryrefslogtreecommitdiff
path: root/lib/libalpm/conflict.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/conflict.c')
-rw-r--r--lib/libalpm/conflict.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index c093705a..f666d595 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -49,12 +49,19 @@ pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2)
MALLOC(conflict, sizeof(pmconflict_t), RET_ERR(PM_ERR_MEMORY, NULL));
- strncpy(conflict->package1, package1, PKG_NAME_LEN);
- strncpy(conflict->package2, package2, PKG_NAME_LEN);
+ STRDUP(conflict->package1, package1, RET_ERR(PM_ERR_MEMORY, NULL));
+ STRDUP(conflict->package2, package2, RET_ERR(PM_ERR_MEMORY, NULL));
return(conflict);
}
+void _alpm_conflict_free(pmconflict_t *conflict)
+{
+ FREE(conflict->package2);
+ FREE(conflict->package1);
+ FREE(conflict);
+}
+
int _alpm_conflict_isin(pmconflict_t *needle, alpm_list_t *haystack)
{
alpm_list_t *i;
@@ -86,7 +93,7 @@ static int does_conflict(pmpkg_t *pkg1, const char *conflict, pmpkg_t *pkg2)
{
const char *pkg1name = alpm_pkg_get_name(pkg1);
const char *pkg2name = alpm_pkg_get_name(pkg2);
- pmdepend_t *conf = alpm_splitdep(conflict);
+ pmdepend_t *conf = _alpm_splitdep(conflict);
int match = 0;
match = alpm_depcmp(pkg2, conf);
@@ -94,7 +101,7 @@ static int does_conflict(pmpkg_t *pkg1, const char *conflict, pmpkg_t *pkg2)
_alpm_log(PM_LOG_DEBUG, "package %s conflicts with %s (by %s)\n",
pkg1name, pkg2name, conflict);
}
- FREE(conf);
+ _alpm_dep_free(conf);
return(match);
}
@@ -110,7 +117,7 @@ static void add_conflict(alpm_list_t **baddeps, const char *pkg1,
if(conflict && !_alpm_conflict_isin(conflict, *baddeps)) {
*baddeps = alpm_list_add(*baddeps, conflict);
} else {
- FREE(conflict);
+ _alpm_conflict_free(conflict);
}
}
@@ -293,15 +300,15 @@ static alpm_list_t *add_fileconflict(alpm_list_t *conflicts,
const char* name1, const char* name2)
{
pmfileconflict_t *conflict;
- MALLOC(conflict, sizeof(pmfileconflict_t), return(conflicts));
+ MALLOC(conflict, sizeof(pmfileconflict_t), RET_ERR(PM_ERR_MEMORY, NULL));
conflict->type = type;
- strncpy(conflict->target, name1, PKG_NAME_LEN);
- strncpy(conflict->file, filestr, CONFLICT_FILE_LEN);
+ STRDUP(conflict->target, name1, RET_ERR(PM_ERR_MEMORY, NULL));
+ STRDUP(conflict->file, filestr, RET_ERR(PM_ERR_MEMORY, NULL));
if(name2) {
- strncpy(conflict->ctarget, name2, PKG_NAME_LEN);
+ STRDUP(conflict->ctarget, name2, RET_ERR(PM_ERR_MEMORY, NULL));
} else {
- conflict->ctarget[0] = '\0';
+ conflict->ctarget = "";
}
conflicts = alpm_list_add(conflicts, conflict);
@@ -311,6 +318,16 @@ static alpm_list_t *add_fileconflict(alpm_list_t *conflicts,
return(conflicts);
}
+void _alpm_fileconflict_free(pmfileconflict_t *conflict)
+{
+ if(strlen(conflict->ctarget) > 0) {
+ FREE(conflict->ctarget);
+ }
+ FREE(conflict->file);;
+ FREE(conflict->target);
+ FREE(conflict);
+}
+
/* Find file conflicts that may occur during the transaction with two checks:
* 1: check every target against every target
* 2: check every target against the filesystem */