X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=xsh%2Fptable.h;h=89b3bbf5e86d744bf0d3ae7181ff6ff07f2b4e3e;hp=af2e168877aab46b5c976469b12524aff390ad72;hb=b2f0fe94a79e6c4426f2b566bd06e5acf9f42c02;hpb=7b9a8ae944bb32360e3a8807ec6cb05376fd4183 diff --git a/xsh/ptable.h b/xsh/ptable.h index af2e168..89b3bbf 100644 --- a/xsh/ptable.h +++ b/xsh/ptable.h @@ -6,7 +6,8 @@ /* This header is designed to be included several times with different * definitions for PTABLE_NAME and PTABLE_VAL_ALLOC/FREE(). */ -#include "util.h" /* VOID2(), XSH_ASSERT(), xPMS */ +#include "util.h" /* XSH_ASSERT() */ +#include "mem.h" /* xPMS, XSH_SHARED_*() */ /* --- Configuration ------------------------------------------------------- */ @@ -160,9 +161,7 @@ static void ptable_split(pPMS_ ptable *t) { size_t new_size = old_size * 2; size_t i; - ary = VOID2(ptable_ent **, - PerlMemShared_realloc(ary, new_size * sizeof *ary)); - Zero(ary + old_size, new_size - old_size, sizeof *ary); + XSH_SHARED_RECALLOC(ary, old_size, new_size, ptable_ent *); t->max = --new_size; t->ary = ary; @@ -201,8 +200,7 @@ static ptable_ent *ptable_ent_vivify(pPMS_ ptable *t, const void *key) { return ent; } - ent = VOID2(ptable_ent *, PerlMemShared_malloc(sizeof *ent)); - + XSH_SHARED_ALLOC(ent, 1, ptable_ent); ent->key = key; ent->val = NULL; ent->next = t->ary[idx]; @@ -269,11 +267,11 @@ static ptable *ptable_new(pPMS_ size_t init_buckets) { XSH_ASSERT(init_buckets >= 4 && ((init_buckets & (init_buckets - 1)) == 0)); - t = VOID2(ptable *, PerlMemShared_malloc(sizeof *t)); + XSH_SHARED_ALLOC(t, 1, ptable); t->max = init_buckets - 1; t->items = 0; - t->ary = VOID2(ptable_ent **, - PerlMemShared_calloc(t->max + 1, sizeof *t->ary)); + XSH_SHARED_CALLOC(t->ary, t->max + 1, ptable_ent *); + return t; } #endif /* !ptable_new */ @@ -303,7 +301,7 @@ static void *ptable_splice(pPMS_ ptable *t, const void *key, void *new_val) { ent = ptable_ent_detach(t, key); if (ent) { old_val = ent->val; - PerlMemShared_free(ent); + XSH_SHARED_FREE(ent, 1, ptable_ent); } } @@ -387,7 +385,7 @@ static void PTABLE_PREFIX(_delete)(pPTBL_ ptable *t, const void *key) { } #endif - PerlMemShared_free(ent); + XSH_SHARED_FREE(ent, 1, ptable_ent); } # if PTABLE_USE_DEFAULT # define ptable_default_delete ptable_default_delete @@ -411,7 +409,7 @@ static void PTABLE_PREFIX(_clear)(pPTBL_ ptable *t) { #ifdef PTABLE_VAL_FREE PTABLE_VAL_FREE(entry->val); #endif - PerlMemShared_free(entry); + XSH_SHARED_FREE(entry, 1, ptable_ent); entry = nentry; } array[idx] = NULL; @@ -432,8 +430,8 @@ static void PTABLE_PREFIX(_free)(pPTBL_ ptable *t) { if (!t) return; PTABLE_PREFIX(_clear)(aPTBL_ t); - PerlMemShared_free(t->ary); - PerlMemShared_free(t); + XSH_SHARED_FREE(t->ary, t->max + 1, ptable_ent *); + XSH_SHARED_FREE(t, 1, ptable); } # if PTABLE_USE_DEFAULT # define ptable_default_free ptable_default_free