library/src/datastructures/BP-LinkedList.cc
// adds data to the front of the list (push front)
adds data to the front of the list (push front)
adds data to the front of the list ( push front )
BP_ERROR_T BP_AddDataToLinkLHead(P_BP_LINKL head, void * data, size_t data_size,  BP_MEMPROF_ALLOC_TYPE type, BPLN_PARMS)
{
	if(!head)
		return ERR_FAILURE;
	if(!data)
		return ERR_FAILURE;
	if(!data_size)
		return ERR_FAILURE;
	P_BP_LINKL_DATA new_data = (P_BP_LINKL_DATA) bpcalloc(sizeof(BP_LINKL_DATA), 1);
	if(!new_data)
		return ERR_FAILURE;
	new_data->data      = data;
	new_data->data_size = data_size;
	new_data->data_type = type;
	if(file_name)
		new_data->file = (char *) bpstrdup(file_name);
	if(line_number)
		new_data->line_number = line_number;
	if(func)
		new_data->function = (char *) bpstrdup(func);
	if(head->thread_safe_enabled)
		sem_wait(&head->thread_safe_semaphore);
	TAILQ_INSERT_HEAD(&head->head, new_data, linkl_data);
	head->total_size += data_size;
	head->total_allocations++;
	if(head->thread_safe_enabled)
		sem_post(&head->thread_safe_semaphore);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_AddDataToLinkLHead ( P_BP_LINKL head , void * data , size_t data_size , BP_MEMPROF_ALLOC_TYPE type , BPLN_PARMS ) { if ( ! head ) return ERR_FAILURE ; if ( ! data ) return ERR_FAILURE ; if ( ! data_size ) return ERR_FAILURE ; P_BP_LINKL_DATA new_data = ( P_BP_LINKL_DATA ) bpcalloc ( sizeof ( BP_LINKL_DATA ) , 1 ) ; if ( ! new_data ) return ERR_FAILURE ; new_data -> data = data ; new_data -> data_size = data_size ; new_data -> data_type = type ; if ( file_name ) new_data -> file = ( char * ) bpstrdup ( file_name ) ; if ( line_number ) new_data -> line_number = line_number ; if ( func ) new_data -> function = ( char * ) bpstrdup ( func ) ; if ( head -> thread_safe_enabled ) sem_wait ( & head -> thread_safe_semaphore ) ; TAILQ_INSERT_HEAD ( & head -> head , new_data , linkl_data ) ; head -> total_size += data_size ; head -> total_allocations ++ ; if ( head -> thread_safe_enabled ) sem_post ( & head -> thread_safe_semaphore ) ; return ERR_SUCCESS ; }
adds data to the front of the list (push front)
adds data to the front of the list ( push front )
// create new data // add debugging info if set // reconfigure semaphore // insert a new item into the queue // increment the data size // reconfigure semaphore // return indicating success