/* 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 ------------------------------------------------------- */
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;
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];
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 */
ent = ptable_ent_detach(t, key);
if (ent) {
old_val = ent->val;
- PerlMemShared_free(ent);
+ XSH_SHARED_FREE(ent, 1, ptable_ent);
}
}
}
#endif
- PerlMemShared_free(ent);
+ XSH_SHARED_FREE(ent, 1, ptable_ent);
}
# if PTABLE_USE_DEFAULT
# define ptable_default_delete ptable_default_delete
#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;
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