示例#1
0
文件: hash.c 项目: u1f35c/onak
/**
 *	free_statskey - free an stats key structure.
 *	@key: The key to free.
 *
 *	Takes a stats key and frees the memory used by it and the linked list
 *	of sigs under it. Doesn't recurse into the list as it's assumed all the
 *	objects referenced also exist in the hash.
 */
static void free_statskey(struct stats_key *key)
{
	if (key != NULL) {
		if (key->sigs != NULL) {
			llfree(key->sigs, NULL);
			key->sigs = NULL;
		}
		if (key->signs != NULL) {
			llfree(key->signs, NULL);
			key->signs = NULL;
		}
		free(key);
	}
}
示例#2
0
/**
   free a linked list.
 */
void 
llfree(linkedlist* a)
{				/* add paranoia checks */
  if (!a)
    return;
  llfree(a->next);
  a->next = NULL;
  free (a->string);  
  a->string = NULL;
  free (a);  
}
示例#3
0
文件: hash.c 项目: u1f35c/onak
/**
 *	destroyhash - Clean up the hash after use.
 *
 *	This function destroys the hash after use, freeing any memory that was
 *	used during its lifetime.
 */
void destroyhash(void)
{
	int i;
	struct ll *curll = NULL;

	for (i = 0; i < HASHSIZE; i++) {
		curll = hashtable[i];
		/*
		 * TODO: The problem is the object has pointers that
		 * need freed too.
		 */
		llfree(curll, (void (*)(void *)) free_statskey);
		hashtable[i] = NULL;
	}
	elements = 0;
}