Пример #1
0
void myfree(char* file, int line, void* p)
{
	ListElement* e = ListFindItem(&heap, p, ptrCompare);
	if (e == NULL)
		Log(LOG_ERROR, Messages_get(99), file, line);
	else
	{
		storageElement* s = (storageElement*)(heap.current->content);
		//Log(LOG_DEBUG, "Freeing %d bytes in heap at file %s line %d, heap use now %d bytes\n", s->size, file, line, state.current_size);
		free(s->file);
		state.current_size -= s->size;
		ListRemoveCurrentItem(&heap);
	}
	free(p);
}
Пример #2
0
/**
 * Remove an item from the recorded heap without actually freeing it.
 * Use sparingly!
 * @param file use the __FILE__ macro to indicate which file this item was allocated in
 * @param line use the __LINE__ macro to indicate which line this item was allocated at
 * @param p pointer to the item to be removed
 */
void Internal_heap_unlink(char* file, int line, void* p)
{
	ListElement* e = NULL;

	if ((e = ListFindItem(&heap, p, ptrCompare)) == NULL)
		Log(LOG_ERROR, -1, "Failed to remove heap item at file %s line %d", file, line);
	else
	{
		storageElement* s = (storageElement*)(heap.current->content);
		Log(TRACE_MAX, -1, "Freeing %d bytes in heap at file %s line %d, heap use now %d bytes",
											 s->size, file, line, state.current_size);
		free(s->file);
		if (s->stack)
			free(s->stack);
		state.current_size -= s->size;
		ListRemoveCurrentItem(&heap);
	}
}