X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=ptable.h;h=055f0a5cd008d2471c620c8321996e023e118a7a;hb=3726dd28139789d99ab213bf25d9a2b0509cb756;hp=b3d19e23416f16b6941f24753ed5c81f3bec41b1;hpb=bdc2a15aa5ca3f57b45d2c6e560f110c91b2ae87;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/ptable.h b/ptable.h index b3d19e2..055f0a5 100644 --- a/ptable.h +++ b/ptable.h @@ -176,6 +176,27 @@ STATIC void PTABLE_PREFIX(_store)(pPTBL_ ptable * const t, const void * const ke } } +STATIC void PTABLE_PREFIX(_delete)(pPTBL_ ptable * const t, const void * const key) { + ptable_ent *prev, *ent; + const size_t i = PTABLE_HASH(key) & t->max; + + prev = NULL; + ent = t->ary[i]; + for (; ent; prev = ent, ent = ent->next) { + if (ent->key == key) + break; + } + + if (ent) { + if (prev) + prev->next = ent->next; + else + t->ary[i] = ent->next; + PTABLE_VAL_FREE(ent->val); + PerlMemShared_free(ent); + } +} + #ifndef ptable_walk STATIC void ptable_walk(pTHX_ ptable * const t, void (*cb)(pTHX_ ptable_ent *ent, void *userdata), void *userdata) { #define ptable_walk(T, CB, UD) ptable_walk(aTHX_ (T), (CB), (UD))