mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-08 12:28:00 -05:00
alpm: export *_free functions
Front-ends should be able to free memory that alpm hands them. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
953808a9ee
commit
b9601b1e59
@ -1351,6 +1351,10 @@ enum alpm_caps {
|
|||||||
const char *alpm_version(void);
|
const char *alpm_version(void);
|
||||||
enum alpm_caps alpm_capabilities(void);
|
enum alpm_caps alpm_capabilities(void);
|
||||||
|
|
||||||
|
void alpm_fileconflict_free(alpm_fileconflict_t *conflict);
|
||||||
|
void alpm_depmissing_free(alpm_depmissing_t *miss);
|
||||||
|
void alpm_conflict_free(alpm_conflict_t *conflict);
|
||||||
|
|
||||||
/* End of alpm_api */
|
/* End of alpm_api */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
|
|||||||
/**
|
/**
|
||||||
* @brief Free a conflict and its members.
|
* @brief Free a conflict and its members.
|
||||||
*/
|
*/
|
||||||
void _alpm_conflict_free(alpm_conflict_t *conflict)
|
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
|
||||||
{
|
{
|
||||||
FREE(conflict->package2);
|
FREE(conflict->package2);
|
||||||
FREE(conflict->package1);
|
FREE(conflict->package1);
|
||||||
@ -135,7 +135,7 @@ static int add_conflict(alpm_handle_t *handle, alpm_list_t **baddeps,
|
|||||||
pkg1->name, pkg2->name, conflict_str);
|
pkg1->name, pkg2->name, conflict_str);
|
||||||
free(conflict_str);
|
free(conflict_str);
|
||||||
} else {
|
} else {
|
||||||
_alpm_conflict_free(conflict);
|
alpm_conflict_free(conflict);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ error:
|
|||||||
/**
|
/**
|
||||||
* @brief Frees a conflict and its members.
|
* @brief Frees a conflict and its members.
|
||||||
*/
|
*/
|
||||||
void _alpm_fileconflict_free(alpm_fileconflict_t *conflict)
|
void SYMEXPORT alpm_fileconflict_free(alpm_fileconflict_t *conflict)
|
||||||
{
|
{
|
||||||
FREE(conflict->ctarget);
|
FREE(conflict->ctarget);
|
||||||
FREE(conflict->file);
|
FREE(conflict->file);
|
||||||
|
@ -25,14 +25,11 @@
|
|||||||
#include "package.h"
|
#include "package.h"
|
||||||
|
|
||||||
alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict);
|
alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict);
|
||||||
void _alpm_conflict_free(alpm_conflict_t *conflict);
|
|
||||||
alpm_list_t *_alpm_innerconflicts(alpm_handle_t *handle, alpm_list_t *packages);
|
alpm_list_t *_alpm_innerconflicts(alpm_handle_t *handle, alpm_list_t *packages);
|
||||||
alpm_list_t *_alpm_outerconflicts(alpm_db_t *db, alpm_list_t *packages);
|
alpm_list_t *_alpm_outerconflicts(alpm_db_t *db, alpm_list_t *packages);
|
||||||
alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
||||||
alpm_list_t *upgrade, alpm_list_t *remove);
|
alpm_list_t *upgrade, alpm_list_t *remove);
|
||||||
|
|
||||||
void _alpm_fileconflict_free(alpm_fileconflict_t *conflict);
|
|
||||||
|
|
||||||
#endif /* _ALPM_CONFLICT_H */
|
#endif /* _ALPM_CONFLICT_H */
|
||||||
|
|
||||||
/* vim: set noet: */
|
/* vim: set noet: */
|
||||||
|
@ -57,7 +57,7 @@ static alpm_depmissing_t *depmiss_new(const char *target, alpm_depend_t *dep,
|
|||||||
return miss;
|
return miss;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _alpm_depmiss_free(alpm_depmissing_t *miss)
|
void SYMEXPORT alpm_depmissing_free(alpm_depmissing_t *miss)
|
||||||
{
|
{
|
||||||
_alpm_dep_free(miss->depend);
|
_alpm_dep_free(miss->depend);
|
||||||
FREE(miss->target);
|
FREE(miss->target);
|
||||||
@ -804,7 +804,7 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
|
|||||||
/* check if one of the packages in the [*packages] list already satisfies
|
/* check if one of the packages in the [*packages] list already satisfies
|
||||||
* this dependency */
|
* this dependency */
|
||||||
if(find_dep_satisfier(*packages, missdep)) {
|
if(find_dep_satisfier(*packages, missdep)) {
|
||||||
_alpm_depmiss_free(miss);
|
alpm_depmissing_free(miss);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* check if one of the packages in the [preferred] list already satisfies
|
/* check if one of the packages in the [preferred] list already satisfies
|
||||||
@ -818,9 +818,9 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
|
|||||||
_alpm_log(handle, ALPM_LOG_DEBUG,
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
||||||
"pulling dependency %s (needed by %s)\n",
|
"pulling dependency %s (needed by %s)\n",
|
||||||
spkg->name, pkg->name);
|
spkg->name, pkg->name);
|
||||||
_alpm_depmiss_free(miss);
|
alpm_depmissing_free(miss);
|
||||||
} else if(resolvedep(handle, missdep, (targ = alpm_list_add(NULL, handle->db_local)), rem, 0)) {
|
} else if(resolvedep(handle, missdep, (targ = alpm_list_add(NULL, handle->db_local)), rem, 0)) {
|
||||||
_alpm_depmiss_free(miss);
|
alpm_depmissing_free(miss);
|
||||||
} else {
|
} else {
|
||||||
handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
|
handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
|
||||||
char *missdepstring = alpm_dep_compute_string(missdep);
|
char *missdepstring = alpm_dep_compute_string(missdep);
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
void _alpm_dep_free(alpm_depend_t *dep);
|
void _alpm_dep_free(alpm_depend_t *dep);
|
||||||
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep);
|
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep);
|
||||||
void _alpm_depmiss_free(alpm_depmissing_t *miss);
|
|
||||||
alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
|
alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
|
||||||
alpm_list_t *targets, alpm_list_t *ignore, int reverse);
|
alpm_list_t *targets, alpm_list_t *ignore, int reverse);
|
||||||
int _alpm_recursedeps(alpm_db_t *db, alpm_list_t **targs, int include_explicit);
|
int _alpm_recursedeps(alpm_db_t *db, alpm_list_t **targs, int include_explicit);
|
||||||
|
@ -116,7 +116,7 @@ static int remove_prepare_cascade(alpm_handle_t *handle, alpm_list_t *lp)
|
|||||||
_("could not find %s in database -- skipping\n"), miss->target);
|
_("could not find %s in database -- skipping\n"), miss->target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
|
alpm_list_free_inner(lp, (alpm_list_fn_free)alpm_depmissing_free);
|
||||||
alpm_list_free(lp);
|
alpm_list_free(lp);
|
||||||
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
|
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
|
||||||
trans->remove, NULL, 1);
|
trans->remove, NULL, 1);
|
||||||
@ -153,7 +153,7 @@ static void remove_prepare_keep_needed(alpm_handle_t *handle, alpm_list_t *lp)
|
|||||||
_alpm_pkg_free(pkg);
|
_alpm_pkg_free(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
|
alpm_list_free_inner(lp, (alpm_list_fn_free)alpm_depmissing_free);
|
||||||
alpm_list_free(lp);
|
alpm_list_free(lp);
|
||||||
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
|
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
|
||||||
trans->remove, NULL, 1);
|
trans->remove, NULL, 1);
|
||||||
@ -232,7 +232,8 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
if(data) {
|
if(data) {
|
||||||
*data = lp;
|
*data = lp;
|
||||||
} else {
|
} else {
|
||||||
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
|
alpm_list_free_inner(lp,
|
||||||
|
(alpm_list_fn_free)alpm_depmissing_free);
|
||||||
alpm_list_free(lp);
|
alpm_list_free(lp);
|
||||||
}
|
}
|
||||||
RET_ERR(handle, ALPM_ERR_UNSATISFIED_DEPS, -1);
|
RET_ERR(handle, ALPM_ERR_UNSATISFIED_DEPS, -1);
|
||||||
|
@ -451,7 +451,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
dependency-reordered list below */
|
dependency-reordered list below */
|
||||||
handle->pm_errno = 0;
|
handle->pm_errno = 0;
|
||||||
if(data) {
|
if(data) {
|
||||||
alpm_list_free_inner(*data, (alpm_list_fn_free)_alpm_depmiss_free);
|
alpm_list_free_inner(*data,
|
||||||
|
(alpm_list_fn_free)alpm_depmissing_free);
|
||||||
alpm_list_free(*data);
|
alpm_list_free(*data);
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
}
|
}
|
||||||
@ -527,7 +528,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
*data = alpm_list_add(*data, newconflict);
|
*data = alpm_list_add(*data, newconflict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
alpm_list_free_inner(deps, (alpm_list_fn_free)alpm_conflict_free);
|
||||||
alpm_list_free(deps);
|
alpm_list_free(deps);
|
||||||
_alpm_dep_free(dep1);
|
_alpm_dep_free(dep1);
|
||||||
_alpm_dep_free(dep2);
|
_alpm_dep_free(dep2);
|
||||||
@ -545,7 +546,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
trans->unresolvable = alpm_list_add(trans->unresolvable, rsync);
|
trans->unresolvable = alpm_list_add(trans->unresolvable, rsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
alpm_list_free_inner(deps, (alpm_list_fn_free)alpm_conflict_free);
|
||||||
alpm_list_free(deps);
|
alpm_list_free(deps);
|
||||||
deps = NULL;
|
deps = NULL;
|
||||||
|
|
||||||
@ -591,13 +592,13 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
*data = alpm_list_add(*data, newconflict);
|
*data = alpm_list_add(*data, newconflict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
alpm_list_free_inner(deps, (alpm_list_fn_free)alpm_conflict_free);
|
||||||
alpm_list_free(deps);
|
alpm_list_free(deps);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EVENT(handle, ALPM_EVENT_INTERCONFLICTS_DONE, NULL, NULL);
|
EVENT(handle, ALPM_EVENT_INTERCONFLICTS_DONE, NULL, NULL);
|
||||||
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
alpm_list_free_inner(deps, (alpm_list_fn_free)alpm_conflict_free);
|
||||||
alpm_list_free(deps);
|
alpm_list_free(deps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,7 +628,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
if(data) {
|
if(data) {
|
||||||
*data = deps;
|
*data = deps;
|
||||||
} else {
|
} else {
|
||||||
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_depmiss_free);
|
alpm_list_free_inner(deps,
|
||||||
|
(alpm_list_fn_free)alpm_depmissing_free);
|
||||||
alpm_list_free(deps);
|
alpm_list_free(deps);
|
||||||
}
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1273,7 +1275,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
if(data) {
|
if(data) {
|
||||||
*data = conflict;
|
*data = conflict;
|
||||||
} else {
|
} else {
|
||||||
alpm_list_free_inner(conflict, (alpm_list_fn_free)_alpm_fileconflict_free);
|
alpm_list_free_inner(conflict, (alpm_list_fn_free)alpm_fileconflict_free);
|
||||||
alpm_list_free(conflict);
|
alpm_list_free(conflict);
|
||||||
}
|
}
|
||||||
RET_ERR(handle, ALPM_ERR_FILE_CONFLICTS, -1);
|
RET_ERR(handle, ALPM_ERR_FILE_CONFLICTS, -1);
|
||||||
|
@ -121,12 +121,13 @@ int pacman_remove(alpm_list_t *targets)
|
|||||||
char *depstring = alpm_dep_compute_string(miss->depend);
|
char *depstring = alpm_dep_compute_string(miss->depend);
|
||||||
colon_printf(_("%s: requires %s\n"), miss->target, depstring);
|
colon_printf(_("%s: requires %s\n"), miss->target, depstring);
|
||||||
free(depstring);
|
free(depstring);
|
||||||
|
alpm_depmissing_free(miss);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FREELIST(data);
|
alpm_list_free(data);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -764,8 +764,9 @@ int sync_prepare_execute(void)
|
|||||||
switch(err) {
|
switch(err) {
|
||||||
case ALPM_ERR_PKG_INVALID_ARCH:
|
case ALPM_ERR_PKG_INVALID_ARCH:
|
||||||
for(i = data; i; i = alpm_list_next(i)) {
|
for(i = data; i; i = alpm_list_next(i)) {
|
||||||
const char *pkg = i->data;
|
char *pkg = i->data;
|
||||||
colon_printf(_("package %s does not have a valid architecture\n"), pkg);
|
colon_printf(_("package %s does not have a valid architecture\n"), pkg);
|
||||||
|
free(pkg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_ERR_UNSATISFIED_DEPS:
|
case ALPM_ERR_UNSATISFIED_DEPS:
|
||||||
@ -774,6 +775,7 @@ int sync_prepare_execute(void)
|
|||||||
char *depstring = alpm_dep_compute_string(miss->depend);
|
char *depstring = alpm_dep_compute_string(miss->depend);
|
||||||
colon_printf(_("%s: requires %s\n"), miss->target, depstring);
|
colon_printf(_("%s: requires %s\n"), miss->target, depstring);
|
||||||
free(depstring);
|
free(depstring);
|
||||||
|
alpm_depmissing_free(miss);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_ERR_CONFLICTING_DEPS:
|
case ALPM_ERR_CONFLICTING_DEPS:
|
||||||
@ -789,6 +791,7 @@ int sync_prepare_execute(void)
|
|||||||
conflict->package1, conflict->package2, reason);
|
conflict->package1, conflict->package2, reason);
|
||||||
free(reason);
|
free(reason);
|
||||||
}
|
}
|
||||||
|
alpm_conflict_free(conflict);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -848,6 +851,7 @@ int sync_prepare_execute(void)
|
|||||||
conflict->target, conflict->file);
|
conflict->target, conflict->file);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
alpm_fileconflict_free(conflict);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_ERR_PKG_INVALID:
|
case ALPM_ERR_PKG_INVALID:
|
||||||
@ -855,8 +859,9 @@ int sync_prepare_execute(void)
|
|||||||
case ALPM_ERR_PKG_INVALID_SIG:
|
case ALPM_ERR_PKG_INVALID_SIG:
|
||||||
case ALPM_ERR_DLT_INVALID:
|
case ALPM_ERR_DLT_INVALID:
|
||||||
for(i = data; i; i = alpm_list_next(i)) {
|
for(i = data; i; i = alpm_list_next(i)) {
|
||||||
const char *filename = i->data;
|
char *filename = i->data;
|
||||||
printf(_("%s is invalid or corrupted\n"), filename);
|
printf(_("%s is invalid or corrupted\n"), filename);
|
||||||
|
free(filename);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -870,9 +875,7 @@ int sync_prepare_execute(void)
|
|||||||
|
|
||||||
/* Step 4: release transaction resources */
|
/* Step 4: release transaction resources */
|
||||||
cleanup:
|
cleanup:
|
||||||
if(data) {
|
alpm_list_free(data);
|
||||||
FREELIST(data);
|
|
||||||
}
|
|
||||||
if(trans_release() == -1) {
|
if(trans_release() == -1) {
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user