testdb : fix many memleaks
Yes, it was that bad :P We still have memleaks left because we cannot free the error data returned by libalpm, but pacman has the same issue. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
03470c51ca
commit
0f834c93c7
1 changed files with 14 additions and 4 deletions
|
@ -92,6 +92,11 @@ static int db_test(char *dbpath, int local)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(closedir(dir)) {
|
||||||
|
fprintf(stderr, "error closing dbpath : %s\n", strerror(errno));
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +115,7 @@ int checkdeps(alpm_list_t *pkglist)
|
||||||
free(depstring);
|
free(depstring);
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
|
FREELIST(data);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +131,7 @@ int checkconflicts(alpm_list_t *pkglist)
|
||||||
alpm_conflict_get_package2(conflict));
|
alpm_conflict_get_package2(conflict));
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
|
FREELIST(data);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,21 +170,23 @@ int check_syncdbs(char *dbpath, alpm_list_t *dbnames) {
|
||||||
snprintf(syncdbpath, PATH_MAX, "%s/sync/%s", dbpath, dbname);
|
snprintf(syncdbpath, PATH_MAX, "%s/sync/%s", dbpath, dbname);
|
||||||
ret = db_test(syncdbpath, 0);
|
ret = db_test(syncdbpath, 0);
|
||||||
if(ret) {
|
if(ret) {
|
||||||
return(ret);
|
ret = 1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
db = alpm_db_register_sync(dbname);
|
db = alpm_db_register_sync(dbname);
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
fprintf(stderr, "error: could not register sync database (%s)\n",
|
fprintf(stderr, "error: could not register sync database (%s)\n",
|
||||||
alpm_strerrorlast());
|
alpm_strerrorlast());
|
||||||
cleanup(EXIT_FAILURE);
|
ret = 1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
pkglist = alpm_db_get_pkgcache(db);
|
pkglist = alpm_db_get_pkgcache(db);
|
||||||
syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist));
|
syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist));
|
||||||
}
|
}
|
||||||
ret += checkdeps(syncpkglist);
|
ret += checkdeps(syncpkglist);
|
||||||
alpm_list_free(syncpkglist);
|
|
||||||
|
|
||||||
alpm_db_unregister_all();
|
cleanup:
|
||||||
|
alpm_list_free(syncpkglist);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +236,7 @@ int main(int argc, char **argv)
|
||||||
ret = check_localdb(dbpath);
|
ret = check_localdb(dbpath);
|
||||||
} else {
|
} else {
|
||||||
ret = check_syncdbs(dbpath,dbnames);
|
ret = check_syncdbs(dbpath,dbnames);
|
||||||
|
alpm_list_free(dbnames);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup(ret);
|
cleanup(ret);
|
||||||
|
|
Loading…
Add table
Reference in a new issue