Rename pmpkghash_t to alpm_pkghash_t
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
57b9b19b10
commit
71fa9f912d
4 changed files with 26 additions and 26 deletions
|
@ -484,7 +484,7 @@ void _alpm_db_free_pkgcache(alpm_db_t *db)
|
||||||
_alpm_db_free_grpcache(db);
|
_alpm_db_free_grpcache(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
pmpkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db)
|
alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db)
|
||||||
{
|
{
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -503,7 +503,7 @@ pmpkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db)
|
||||||
|
|
||||||
alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db)
|
alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db)
|
||||||
{
|
{
|
||||||
pmpkghash_t *hash = _alpm_db_get_pkgcache_hash(db);
|
alpm_pkghash_t *hash = _alpm_db_get_pkgcache_hash(db);
|
||||||
|
|
||||||
if(hash == NULL) {
|
if(hash == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -567,7 +567,7 @@ alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pmpkghash_t *pkgcache = _alpm_db_get_pkgcache_hash(db);
|
alpm_pkghash_t *pkgcache = _alpm_db_get_pkgcache_hash(db);
|
||||||
if(!pkgcache) {
|
if(!pkgcache) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ struct __alpm_db_t {
|
||||||
int is_local;
|
int is_local;
|
||||||
/* flags determining validity, loaded caches, etc. */
|
/* flags determining validity, loaded caches, etc. */
|
||||||
enum _pmdbstatus_t status;
|
enum _pmdbstatus_t status;
|
||||||
pmpkghash_t *pkgcache;
|
alpm_pkghash_t *pkgcache;
|
||||||
alpm_list_t *grpcache;
|
alpm_list_t *grpcache;
|
||||||
alpm_list_t *servers;
|
alpm_list_t *servers;
|
||||||
pgp_verify_t pgp_verify;
|
pgp_verify_t pgp_verify;
|
||||||
|
@ -97,7 +97,7 @@ int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info);
|
||||||
void _alpm_db_free_pkgcache(alpm_db_t *db);
|
void _alpm_db_free_pkgcache(alpm_db_t *db);
|
||||||
int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg);
|
int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg);
|
||||||
int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg);
|
int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg);
|
||||||
pmpkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db);
|
alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db);
|
||||||
alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db);
|
alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db);
|
||||||
int _alpm_db_ensure_pkgcache(alpm_db_t *db, pmdbinfrq_t infolevel);
|
int _alpm_db_ensure_pkgcache(alpm_db_t *db, pmdbinfrq_t infolevel);
|
||||||
alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target);
|
alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target);
|
||||||
|
|
|
@ -51,12 +51,12 @@ static const size_t prime_list[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Allocate a hash table with at least "size" buckets */
|
/* Allocate a hash table with at least "size" buckets */
|
||||||
pmpkghash_t *_alpm_pkghash_create(size_t size)
|
alpm_pkghash_t *_alpm_pkghash_create(size_t size)
|
||||||
{
|
{
|
||||||
pmpkghash_t *hash = NULL;
|
alpm_pkghash_t *hash = NULL;
|
||||||
size_t i, loopsize;
|
size_t i, loopsize;
|
||||||
|
|
||||||
CALLOC(hash, 1, sizeof(pmpkghash_t), return NULL);
|
CALLOC(hash, 1, sizeof(alpm_pkghash_t), return NULL);
|
||||||
|
|
||||||
loopsize = sizeof(prime_list) / sizeof(*prime_list);
|
loopsize = sizeof(prime_list) / sizeof(*prime_list);
|
||||||
for(i = 0; i < loopsize; i++) {
|
for(i = 0; i < loopsize; i++) {
|
||||||
|
@ -78,7 +78,7 @@ pmpkghash_t *_alpm_pkghash_create(size_t size)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t get_hash_position(unsigned long name_hash, pmpkghash_t *hash)
|
static size_t get_hash_position(unsigned long name_hash, alpm_pkghash_t *hash)
|
||||||
{
|
{
|
||||||
size_t position;
|
size_t position;
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ static size_t get_hash_position(unsigned long name_hash, pmpkghash_t *hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expand the hash table size to the next increment and rebin the entries */
|
/* Expand the hash table size to the next increment and rebin the entries */
|
||||||
static pmpkghash_t *rehash(pmpkghash_t *oldhash)
|
static alpm_pkghash_t *rehash(alpm_pkghash_t *oldhash)
|
||||||
{
|
{
|
||||||
pmpkghash_t *newhash;
|
alpm_pkghash_t *newhash;
|
||||||
size_t newsize, position, i;
|
size_t newsize, position, i;
|
||||||
|
|
||||||
/* Hash tables will need resized in two cases:
|
/* Hash tables will need resized in two cases:
|
||||||
|
@ -144,7 +144,7 @@ static pmpkghash_t *rehash(pmpkghash_t *oldhash)
|
||||||
return newhash;
|
return newhash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pmpkghash_t *pkghash_add_pkg(pmpkghash_t *hash, alpm_pkg_t *pkg, int sorted)
|
static alpm_pkghash_t *pkghash_add_pkg(alpm_pkghash_t *hash, alpm_pkg_t *pkg, int sorted)
|
||||||
{
|
{
|
||||||
alpm_list_t *ptr;
|
alpm_list_t *ptr;
|
||||||
size_t position;
|
size_t position;
|
||||||
|
@ -179,17 +179,17 @@ static pmpkghash_t *pkghash_add_pkg(pmpkghash_t *hash, alpm_pkg_t *pkg, int sort
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
pmpkghash_t *_alpm_pkghash_add(pmpkghash_t *hash, alpm_pkg_t *pkg)
|
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t *hash, alpm_pkg_t *pkg)
|
||||||
{
|
{
|
||||||
return pkghash_add_pkg(hash, pkg, 0);
|
return pkghash_add_pkg(hash, pkg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pmpkghash_t *_alpm_pkghash_add_sorted(pmpkghash_t *hash, alpm_pkg_t *pkg)
|
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg)
|
||||||
{
|
{
|
||||||
return pkghash_add_pkg(hash, pkg, 1);
|
return pkghash_add_pkg(hash, pkg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t move_one_entry(pmpkghash_t *hash, size_t start, size_t end)
|
static size_t move_one_entry(alpm_pkghash_t *hash, size_t start, size_t end)
|
||||||
{
|
{
|
||||||
/* Iterate backwards from 'end' to 'start', seeing if any of the items
|
/* Iterate backwards from 'end' to 'start', seeing if any of the items
|
||||||
* would hash to 'start'. If we find one, we move it there and break. If
|
* would hash to 'start'. If we find one, we move it there and break. If
|
||||||
|
@ -226,7 +226,7 @@ static size_t move_one_entry(pmpkghash_t *hash, size_t start, size_t end)
|
||||||
*
|
*
|
||||||
* @return the resultant hash
|
* @return the resultant hash
|
||||||
*/
|
*/
|
||||||
pmpkghash_t *_alpm_pkghash_remove(pmpkghash_t *hash, alpm_pkg_t *pkg,
|
alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
|
||||||
alpm_pkg_t **data)
|
alpm_pkg_t **data)
|
||||||
{
|
{
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
|
@ -283,7 +283,7 @@ pmpkghash_t *_alpm_pkghash_remove(pmpkghash_t *hash, alpm_pkg_t *pkg,
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _alpm_pkghash_free(pmpkghash_t *hash)
|
void _alpm_pkghash_free(alpm_pkghash_t *hash)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
if(hash != NULL) {
|
if(hash != NULL) {
|
||||||
|
@ -295,7 +295,7 @@ void _alpm_pkghash_free(pmpkghash_t *hash)
|
||||||
free(hash);
|
free(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
alpm_pkg_t *_alpm_pkghash_find(pmpkghash_t *hash, const char *name)
|
alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name)
|
||||||
{
|
{
|
||||||
alpm_list_t *lp;
|
alpm_list_t *lp;
|
||||||
unsigned long name_hash;
|
unsigned long name_hash;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
* A combination of a hash table and a list, allowing for fast look-up
|
* A combination of a hash table and a list, allowing for fast look-up
|
||||||
* by package name but also iteration over the packages.
|
* by package name but also iteration over the packages.
|
||||||
*/
|
*/
|
||||||
struct __pmpkghash_t {
|
struct __alpm_pkghash_t {
|
||||||
/** data held by the hash table */
|
/** data held by the hash table */
|
||||||
alpm_list_t **hash_table;
|
alpm_list_t **hash_table;
|
||||||
/** number of buckets in hash table */
|
/** number of buckets in hash table */
|
||||||
|
@ -43,17 +43,17 @@ struct __pmpkghash_t {
|
||||||
alpm_list_t *list;
|
alpm_list_t *list;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct __pmpkghash_t pmpkghash_t;
|
typedef struct __alpm_pkghash_t alpm_pkghash_t;
|
||||||
|
|
||||||
pmpkghash_t *_alpm_pkghash_create(size_t size);
|
alpm_pkghash_t *_alpm_pkghash_create(size_t size);
|
||||||
|
|
||||||
pmpkghash_t *_alpm_pkghash_add(pmpkghash_t *hash, alpm_pkg_t *pkg);
|
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
|
||||||
pmpkghash_t *_alpm_pkghash_add_sorted(pmpkghash_t *hash, alpm_pkg_t *pkg);
|
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
|
||||||
pmpkghash_t *_alpm_pkghash_remove(pmpkghash_t *hash, alpm_pkg_t *pkg, alpm_pkg_t **data);
|
alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg, alpm_pkg_t **data);
|
||||||
|
|
||||||
void _alpm_pkghash_free(pmpkghash_t *hash);
|
void _alpm_pkghash_free(alpm_pkghash_t *hash);
|
||||||
|
|
||||||
alpm_pkg_t *_alpm_pkghash_find(pmpkghash_t *hash, const char *name);
|
alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name);
|
||||||
|
|
||||||
#define MAX_HASH_LOAD 0.7
|
#define MAX_HASH_LOAD 0.7
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue