summaryrefslogtreecommitdiff
path: root/src/pacman/query.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-28 17:41:15 -0600
committerDan McGee <dan@archlinux.org>2011-01-29 12:13:56 -0600
commitef86da97f54a90ee4ba3ba8ea7963135e7bae8ed (patch)
tree99c492d170d3780ac2530413031593cc248a8fd3 /src/pacman/query.c
parent9b876fff09f2af10cba6824bec03d8fe3e167b5b (diff)
Remove need to explicitly register the local DB
Perform the cheap struct and string setup of the local DB at handle initialization time to match the teardown we do when releasing the handle. If the local DB is not needed, all real initialization is done lazily after DB paths and other things have been configured anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/query.c')
-rw-r--r--src/pacman/query.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index fc6a2a56..c79133d1 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -37,8 +37,6 @@
#include "conf.h"
#include "util.h"
-extern pmdb_t *db_local;
-
static char *resolve_path(const char *file)
{
char *str = NULL;
@@ -102,6 +100,7 @@ static int query_fileowner(alpm_list_t *targets)
char *append;
size_t max_length;
alpm_list_t *t;
+ pmdb_t *db_local;
/* This code is here for safety only */
if(targets == NULL) {
@@ -117,6 +116,8 @@ static int query_fileowner(alpm_list_t *targets)
append = path + strlen(path);
max_length = PATH_MAX - (append - path) - 1;
+ db_local = alpm_option_get_localdb();
+
for(t = targets; t; t = alpm_list_next(t)) {
char *filename, *dname, *rpath;
const char *bname;
@@ -220,6 +221,7 @@ static int query_search(alpm_list_t *targets)
{
alpm_list_t *i, *searchlist;
int freelist;
+ pmdb_t *db_local = alpm_option_get_localdb();
/* if we have a targets list, search for packages matching it */
if(targets) {
@@ -286,6 +288,8 @@ static int query_group(alpm_list_t *targets)
alpm_list_t *i, *j;
char *grpname = NULL;
int ret = 0;
+ pmdb_t *db_local = alpm_option_get_localdb();
+
if(targets == NULL) {
for(j = alpm_db_get_grpcache(db_local); j; j = alpm_list_next(j)) {
pmgrp_t *grp = alpm_list_getdata(j);
@@ -471,6 +475,7 @@ int pacman_query(alpm_list_t *targets)
int match = 0;
alpm_list_t *i;
pmpkg_t *pkg = NULL;
+ pmdb_t *db_local;
/* First: operations that do not require targets */
@@ -495,6 +500,8 @@ int pacman_query(alpm_list_t *targets)
}
}
+ db_local = alpm_option_get_localdb();
+
/* operations on all packages in the local DB
* valid: no-op (plain -Q), list, info, check
* invalid: isfile, owns */