library/src/utility/BP-StringUtilities.cc
// returns a heap allocated set of size_t entries corresponding to each individual string in
// the ptrs array.  This is primarily used for linking in existing string arrays to a tailqueue
// allocator.
returns a heap allocated set of size_t entries corresponding to each individual string in
the ptrs array.  This is primarily used for linking in existing string arrays to a tailqueue
allocator.
returns a heap allocated set of size_t entries corresponding to each individual string in the ptrs array . This is primarily used for linking in existing string arrays to a tailqueue allocator .
size_t * BP_CountStringLengthsInStringPointerArrayAndReturnValues(char ** ptrs, size_t max_count, size_t max_line_len)
{
	if(!ptrs || !max_count)
		return NULL;
	size_t * ret_ptrs = (size_t *) NULL;
	size_t n = 0;
	for(; ptrs[n]; n++)
	{
		ret_ptrs = (size_t *) bprealloc(ret_ptrs, sizeof(size_t *) * (n+1));
		if(!ret_ptrs)
			return NULL;
		ret_ptrs[n] = strnlen(ptrs[n], max_line_len);
	}
	return ret_ptrs;
}
size_t * BP_CountStringLengthsInStringPointerArrayAndReturnValues ( char * * ptrs , size_t max_count , size_t max_line_len ) { if ( ! ptrs || ! max_count ) return NULL ; size_t * ret_ptrs = ( size_t * ) NULL ; size_t n = 0 ; for ( ; ptrs [ n ] ; n ++ ) { ret_ptrs = ( size_t * ) bprealloc ( ret_ptrs , sizeof ( size_t * ) * ( n + 1 ) ) ; if ( ! ret_ptrs ) return NULL ; ret_ptrs [ n ] = strnlen ( ptrs [ n ] , max_line_len ) ; } return ret_ptrs ; }
returns a heap allocated set of size_t entries corresponding to each individual string in
the ptrs array.
returns a heap allocated set of size_t entries corresponding to each individual string in the ptrs array .
// ensure parameters are set // pointer which is returned // reallocate space // ensure we've reallocated ok // retrieve string length // return the pointer array