Example #1
0
/*
 * Allocate a node.  Pre-allocation should ensure that the request
 * will always be satisfied.
 */
static __inline struct pctrie_node *
pctrie_node_get(struct pctrie *ptree, pctrie_alloc_t allocfn, uint64_t owner,
    uint16_t count, uint16_t clevel)
{
	struct pctrie_node *node;

	node = allocfn(ptree);
	if (node == NULL)
		return (NULL);
	node->pn_owner = owner;
	node->pn_count = count;
	node->pn_clev = clevel;

	return (node);
}
Example #2
0
cns_Runtime *
cns_startup(cns_Runtime_AllocFn allocfn, cns_Runtime_FreeFn freefn, cns_Runtime_ReallocFn reallocfn, const void * allocContext)
{
    if (!allocfn || !freefn || !reallocfn)
        return 0;

    cns_Error err = CNS_OK;
    cns_Runtime* rv = allocfn(allocContext, sizeof(cns_Runtime), &err);
    if (rv)
    {
        rv->allocfn         = allocfn;
        rv->freefn          = freefn;
        rv->reallocfn       = reallocfn;
        rv->allocContext    = allocContext;
        rv->lastError       = err;
    }
    return rv;
}
void * dAlloc (size_t size)
{
  if (allocfn) return allocfn (size); else return malloc (size);
}