Exemple #1
0
INT32 x_release_mem()
{
	alloc_enter_mutex();

	alloc_obj.buffer = NULL;
	alloc_obj.buf_len = 0;
	alloc_obj.free_list = NULL;
	alloc_obj.status = STATUS_UNAVAILABLE;

	alloc_leave_mutex();

	return SUCCESS;
}
Exemple #2
0
INT32 x_reset_mem()
{
	alloc_enter_mutex();

	alloc_obj.free_list = (struct content_t*)alloc_obj.buffer;
	alloc_obj.free_list->next = NULL;
	alloc_obj.free_list->len = alloc_obj.buf_len - sizeof(struct content_t);
	alloc_obj.status = STATUS_AVAILABLE;

	alloc_leave_mutex();

	return SUCCESS;
}
Exemple #3
0
INT32 x_free(void *addr)
{
	struct content_t *node;

	if (addr == NULL)
		return -1;

	alloc_enter_mutex();

	node = (struct content_t*)((UINT32)addr-sizeof(struct content_t));

	free_content(&alloc_obj.free_list, node);

	alloc_obj.status = STATUS_AVAILABLE;
	alloc_leave_mutex();

	return 0;
}
Exemple #4
0
void *x_alloc(UINT32 size)
{
	struct content_t *node;

	alloc_enter_mutex();
	
	node = alloc_content(&alloc_obj.free_list, size);

	alloc_leave_mutex();

	if (node == NULL)
	{
		alloc_obj.status = STATUS_UNAVAILABLE;
		return NULL;
	}

	return (void*)((UINT32)node+sizeof(struct content_t));
}
Exemple #5
0
INT32 x_free(void *addr)
{
	struct content_t *node;

	if (addr == NULL)
		return -1;

	alloc_enter_mutex();

	node = (struct content_t*)((UINT32)addr-sizeof(struct content_t));

	free_content(&alloc_obj.free_list, node);

	alloc_obj.status = STATUS_AVAILABLE;
	alloc_leave_mutex();

#if (X_ALLOC_DEBUG_LEVEL > 0)
	print_freemem_size();
#endif
	return 0;
}
Exemple #6
0
void *x_alloc(UINT32 size)
{
	struct content_t *node;

	alloc_enter_mutex();
	
	node = alloc_content(&alloc_obj.free_list, size);

	alloc_leave_mutex();
#if (X_ALLOC_DEBUG_LEVEL > 0)
	print_freemem_size();
#endif

	if (node == NULL)
	{
		alloc_obj.status = STATUS_UNAVAILABLE;
		return NULL;
	}

	return (void*)((UINT32)node+sizeof(struct content_t));
}