library/src/datastructures/BP-LinkedList.cc
// creates a new linked list head object
creates a new linked list head object
creates a new linked list head object
P_BP_LINKL BP_CreateLinkL(char *description, BP_BOOL thread_safe)
{
	P_BP_LINKL list = (P_BP_LINKL) bpcalloc(sizeof(BP_LINKL), 1);
	if(!list)
		return NULL;
	if(thread_safe)
	{
		list->thread_safe_enabled = true;
		sem_init(&list->thread_safe_semaphore, 0, 1);
	}
	if(list->thread_safe_enabled)
		sem_wait(&list->thread_safe_semaphore);
	TAILQ_INIT(&list->head);
	if(description)
		strncpy((char *) &list->description, description, sizeof(list->description)-1);
	list->uuid = NEW_RANDOM_UUID;
	if(list->thread_safe_enabled)
		sem_post(&list->thread_safe_semaphore);
	return list;
}
P_BP_LINKL BP_CreateLinkL ( char * description , BP_BOOL thread_safe ) { P_BP_LINKL list = ( P_BP_LINKL ) bpcalloc ( sizeof ( BP_LINKL ) , 1 ) ; if ( ! list ) return NULL ; if ( thread_safe ) { list -> thread_safe_enabled = true ; sem_init ( & list -> thread_safe_semaphore , 0 , 1 ) ; } if ( list -> thread_safe_enabled ) sem_wait ( & list -> thread_safe_semaphore ) ; TAILQ_INIT ( & list -> head ) ; if ( description ) strncpy ( ( char * ) & list -> description , description , sizeof ( list -> description ) - 1 ) ; list -> uuid = NEW_RANDOM_UUID ; if ( list -> thread_safe_enabled ) sem_post ( & list -> thread_safe_semaphore ) ; return list ; }
creates a new linked list head object
creates a new linked list head object
// allocate the new list item // set thread safe enabling here // initialize semaphore // reconfigure semaphore // initialize the queue // copy in the description // assign the uuid as a new random UUID // reconfigure semaphore // return the filled out list