Exemple #1
0
void free_deque_back(deque* d, void (*freefunc)(void*)) {
	while(front(d))
		pop_back(d, freefunc);
	// free the dummy node
	freefunc(d->begin);
	freefunc(d);
}
belle_sip_list_t * belle_sip_list_free_with_data(belle_sip_list_t *list, void (*freefunc)(void*)){
	belle_sip_list_t* elem = list;
	belle_sip_list_t* tmp;
	if (list==NULL) return NULL;
	while(elem->next!=NULL) {
		tmp = elem;
		elem = elem->next;
		freefunc(tmp->data);
		belle_sip_free(tmp);
	}
	freefunc(elem->data);
	belle_sip_free(elem);
	return NULL;
}
bctbx_list_t * bctbx_list_free_with_data(bctbx_list_t *list, bctbx_list_free_func freefunc) {
    bctbx_list_t* elem = list;
    bctbx_list_t* tmp;
    if (list==NULL) return NULL;
    while(elem->next!=NULL) {
        tmp = elem;
        elem = elem->next;
        freefunc(tmp->data);
        bctbx_free(tmp);
    }
    freefunc(elem->data);
    bctbx_free(elem);
    return NULL;
}
	inline CustomHandle<T, freefunc> &operator=(T in)
	{
		if (handle)
			freefunc(handle);
		handle = in;
		return *this;
	}
Exemple #5
0
int
main(int argc, char **argv)
{
	size_t rawlen;
	uint8_t *rawdata;

	if (argc != 2) {
		fprintf(stderr, "Usage: %s <HEXDATA>\n", argv[0]);
		return (EXIT_FAILURE);
	}

	if (!hex_decode(argv[1], &rawdata, &rawlen)) {
		fprintf(stderr, "Error: unable to decode hex\n");
		return (EXIT_FAILURE);
	}

	if (loadfunc(rawdata, rawlen)) {
		testfunc();
		freefunc();
	} else {
		free(rawdata);
		fprintf(stderr, "Error: load function failed\n");
		return (EXIT_FAILURE);
	}

	free(rawdata);

	return (EXIT_SUCCESS);
}
Exemple #6
0
_STACK *sk_deep_copy(_STACK *sk, void *(*copy_func) (void *),
                     void (*freefunc) (void *))
{
    _STACK *ret;
    int i;

    if ((ret = OPENSSL_malloc(sizeof(_STACK))) == NULL)
        return ret;
    ret->comp = sk->comp;
    ret->sorted = sk->sorted;
    ret->num = sk->num;
    ret->num_alloc = sk->num > MIN_NODES ? sk->num : MIN_NODES;
    ret->data = OPENSSL_malloc(sizeof(char *) * ret->num_alloc);
    if (ret->data == NULL) {
        OPENSSL_free(ret);
        return NULL;
    }
    for (i = 0; i < ret->num_alloc; i++)
        ret->data[i] = NULL;

    for (i = 0; i < ret->num; ++i) {
        if (sk->data[i] == NULL)
            continue;
        if ((ret->data[i] = copy_func(sk->data[i])) == NULL) {
            while (--i >= 0)
                if (ret->data[i] != NULL)
                    freefunc(ret->data[i]);
            sk_free(ret);
            return NULL;
        }
    }
    return ret;
}
Exemple #7
0
/* skiplist_delete_free SKIPLIST FREEFUNC
 * Iterate over every element of SKIPLIST, calling FREEFUNC with the value of
 * each, and then delete SKIPLIST itself. If FREEFUNC is NULL, use free(3). */
void skiplist_delete_free(skiplist S, void (*freefunc)(void*)) {
    skiplist_iterator itr;
    if (!freefunc) freefunc = xfree;
    for (itr = skiplist_itr_first(S); itr; itr = skiplist_itr_next(S, itr))
        freefunc(skiplist_itr_value(S, itr));
    skiplist_delete(S);
}
Exemple #8
0
void luaF_freeproto(TProtoFunc *l) {
	while (l) {
		TProtoFunc *next = (TProtoFunc *)l->head.next;
		nblocks -= gcsizeproto(l);
		freefunc(l);
		l = next;
	}
}
Exemple #9
0
void pop_back(deque* d, void (*freefunc)(void*)) {
	if(d->end) {
		node* del = d->end;
		d->end = d->end->prev;
		d->end->next = NULL;
		freefunc(del);
		--d->size;
	}
}
Exemple #10
0
void pop_front(deque* d, void (*freefunc)(void*)) {
	if(d->begin->next) {
		node* del = d->begin->next;
		d->begin->next = del->next;
		if(d->begin->next)								// could be NULL, end doesn't have this problem.
			d->begin->next->prev = d->begin;
		freefunc(del);
		--d->size;
	}
}
Exemple #11
0
/* free all elements in the heap */
void heap_free (heap_t *heap, void (*freefunc) (void *))
{
  assert (heap);
  assert (__heap_is_good (heap));
  for ( ; heap->size; heap->size--)  
   {
     if (heap->element[heap->size].data)
       freefunc (heap->element[heap->size].data);
   }
}
Exemple #12
0
void Float::write(std::ostream& out) const
{
  char* buffer;
  const int bufferSize = gmp_asprintf(&buffer, "%.Fe", value);

  out << buffer;

  void (*freefunc)(void*, size_t);
  mp_get_memory_functions (NULL, NULL, &freefunc);
  freefunc(buffer, bufferSize);
}
void freefunc(struct node* new_node)
{
    for(int t=0;t<27;t++)
    {
        if(new_node->children[t]!=NULL)
        {
            freefunc(new_node->children[t]);       
        }
    }
    free(new_node);
}
Exemple #14
0
MSList * ms_list_free_with_data(MSList *list, void (*freefunc)(void*)){
	MSList *elem;
	MSList *tmp;

	for (elem=list;elem!=NULL;){
		tmp=elem->next;
		if (freefunc) freefunc(elem->data);
		ms_free(elem);
		elem=tmp;
	}
	return NULL;
}
Exemple #15
0
/* ----
 * avl_reset_node() -
 *
 *	avl_reset()'s workhorse.
 * ----
 */
void
avl_reset_node(AVLnode *node, AVLfreefunc *freefunc)
{
	if (node == NULL)
		return;

	avl_reset_node(node->lnode, freefunc);
	avl_reset_node(node->rnode, freefunc);

	if (freefunc != NULL)
		freefunc(node->cdata);
	free(node);
}
Exemple #16
0
void
rmalluserfunc(void)
{
    FUNC *fp;
    long index;

    for (index = 0; index < funccount; index++) {
        fp = functions[index];
        if (fp) {
            freefunc(fp);
            functions[index] = NULL;
        }
    }
}
Exemple #17
0
void array_freeContents(Array *array, void (*freefunc)(void*)) {

  if (array) {

    if (array->isSlice) {
      return;
    }

    freefunc = freefunc ? freefunc : free;
    for (size_t i = 0; i < array->len; ++i) {
      freefunc((void*) array->arr[i]);
    }

  }

}
Exemple #18
0
void
assign(struct namnod *n, const unsigned char *v)
{
	if (n->namflg & N_RDONLY)
		failed(n->namid, wtfailed);

#ifndef RES

	else if (flags & rshflg)
	{
		if (n == &pathnod || eq(n->namid,"SHELL"))
			failed(n->namid, restricted);
	}
#endif

	else if (n->namflg & N_FUNCTN)
	{
		func_unhash(n->namid);
		freefunc(n);

		n->namenv = 0;
		n->namflg = N_DEFAULT;
	}

	if (n == &mchknod)
	{
		mailchk = stoi(v);
	}

	replace(&n->namval, v);
	attrib(n, N_ENVCHG);

	if (n == &pathnod)
	{
		zaphash();
		set_dotpath();
		set_builtins_path();
		return;
	}

	if (flags & prompt)
	{
		if ((n == &mailpnod) || (n == &mailnod && mailpnod.namflg == N_DEFAULT))
			setmail(n->namval);
	}
}
Exemple #19
0
void sysapi_queue_deinit(void (*freefunc)(void *elem, void *magic),
                        void *magic,
                        void *qptr)
{
    struct sysapi_queue_head *qhead = qptr;
    struct sysapi_queue *elem, *prev;
    
    elem = qhead->head;
    prev = elem;
    
    while (elem) {
        if (freefunc) {
            freefunc(elem->data, magic);
        }

        elem = elem->next;
        free(prev);
        prev = elem;
    }
    free(qhead);
}
	inline ~CustomHandle()
	{
		if (handle)
			freefunc(handle);
	}
Exemple #21
0
 ~scoped_ptr()
 {
   freefunc(ptr);
 }
Exemple #22
0
void _jl_gmp_free(void *p)
{
    void (*freefunc) (void *, size_t);
    mp_get_memory_functions (NULL, NULL, &freefunc);
    freefunc(p, 0);
}
/**
 * Unloads dictionary from memory.  Returns true if successful else false.
 */
bool unload(void)
{
    freefunc(root);
    return true;
}