library/src/datastructures/BP-LinkedList.cc
// Duplicate a chunk of memory into our linkl (adds memory to the end of the list)
Duplicate a chunk of memory into our linkl (adds memory to the end of the list)
Duplicate a chunk of memory into our linkl ( adds memory to the end of the list )
void * tq_memdup (P_BP_LINKL head, void *data,  size_t size,    BPLN_PARMS)
{
	if(!head)
		return NULL;
	if(!data)
		return NULL;
	if(!size)
		return NULL;
	void * chunk = bpcalloc( 1, size);
	if(!chunk)
		return NULL;
	memcpy(chunk, data, size);
	if(BP_AddDataToLinkLTail(head, chunk, size , BP_MEMPROF_ALLOC_TYPE_CALLOC, file_name, line_number, func) != ERR_SUCCESS)
	{
		bpfree(chunk);
		chunk = NULL;
		return NULL;
	}
	return chunk;
}
void * tq_memdup ( P_BP_LINKL head , void * data , size_t size , BPLN_PARMS ) { if ( ! head ) return NULL ; if ( ! data ) return NULL ; if ( ! size ) return NULL ; void * chunk = bpcalloc ( 1 , size ) ; if ( ! chunk ) return NULL ; memcpy ( chunk , data , size ) ; if ( BP_AddDataToLinkLTail ( head , chunk , size , BP_MEMPROF_ALLOC_TYPE_CALLOC , file_name , line_number , func ) != ERR_SUCCESS ) { bpfree ( chunk ) ; chunk = NULL ; return NULL ; } return chunk ; }
Duplicate a chunk of memory into our linkl (adds memory to the end of the list)
Duplicate a chunk of memory into our linkl ( adds memory to the end of the list )
// run basic checks // allocate chunk space // copy data into chunk // attempt to add the chunk and return directly // return the chunk