X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=ptable.h;h=6638b600ad74f0dce175404185047e25fe23e405;hp=ba275bac8c717523f844034a31336d817820aaaa;hb=cd669c3d5bb3f70d040109131da334bebed3565e;hpb=8291ef989ac98ee2cb53a6098eed7aa7c3ed0ca8 diff --git a/ptable.h b/ptable.h index ba275ba..6638b60 100644 --- a/ptable.h +++ b/ptable.h @@ -70,8 +70,8 @@ typedef struct ptable_ent { #ifndef ptable typedef struct ptable { ptable_ent **ary; - UV max; - UV items; + size_t max; + size_t items; } ptable; #define ptable ptable #endif /* !ptable */ @@ -117,23 +117,13 @@ STATIC void *ptable_fetch(const ptable * const t, const void * const key) { } #endif /* !ptable_fetch */ -STATIC void PTABLE_PREFIX(_delete)(pPTBL_ const ptable * const t, const void * const key) { - ptable_ent *const ent = ptable_find(t, key); - - if (ent) { - void *val = ent->val; - PTABLE_VAL_FREE(val); - ent->val = NULL; - } -} - #ifndef ptable_split STATIC void ptable_split(pPTBLMS_ ptable * const t) { #define ptable_split(T) ptable_split(aPTBLMS_ (T)) ptable_ent **ary = t->ary; - const UV oldsize = t->max + 1; - UV newsize = oldsize * 2; - UV i; + const size_t oldsize = t->max + 1; + size_t newsize = oldsize * 2; + size_t i; ary = PerlMemShared_realloc(ary, newsize * sizeof(*ary)); Zero(&ary[oldsize], newsize - oldsize, sizeof(*ary)); @@ -165,8 +155,8 @@ STATIC void PTABLE_PREFIX(_store)(pPTBL_ ptable * const t, const void * const ke void *oldval = ent->val; PTABLE_VAL_FREE(oldval); ent->val = val; - } else { - const UV i = PTABLE_HASH(key) & t->max; + } else if (val) { + const size_t i = PTABLE_HASH(key) & t->max; ent = PerlMemShared_malloc(sizeof *ent); ent->key = key; ent->val = val; @@ -183,7 +173,7 @@ STATIC void ptable_walk(pTHX_ ptable * const t, void (*cb)(pTHX_ ptable_ent *ent #define ptable_walk(T, CB, UD) ptable_walk(aTHX_ (T), (CB), (UD)) if (t && t->items) { register ptable_ent ** const array = t->ary; - UV i = t->max; + size_t i = t->max; do { ptable_ent *entry; for (entry = array[i]; entry; entry = entry->next) @@ -196,7 +186,7 @@ STATIC void ptable_walk(pTHX_ ptable * const t, void (*cb)(pTHX_ ptable_ent *ent STATIC void PTABLE_PREFIX(_clear)(pPTBL_ ptable * const t) { if (t && t->items) { register ptable_ent ** const array = t->ary; - UV i = t->max; + size_t i = t->max; do { ptable_ent *entry = array[i];