library/src/utility/BP-NumberUtilities.cc
BP_ERROR_T BP_ArrayPushSizeT(size_t value, size_t ** stack, size_t *stack_n, P_BP_LINKL tq)
{

	// ensure we have a pointer to the stack
	if(!stack_n)
		return ERR_FAILURE;

	// calculate the new stack size based on provided inputs
	size_t new_stack_size = (*stack_n+1) * sizeof(size_t);

	// create new stack
	if(!tq)
		stack[0] = (size_t *) bprealloc(*stack, new_stack_size);
	else
		stack[0] = (size_t *) tq_realloc(tq, *stack, new_stack_size, BPLN);

	// set the value in the gadget stack
	stack[0][*stack_n] = value;

	// increment the stack counter
	*stack_n = *stack_n + 1;

	// return indicating success
	return ERR_SUCCESS;

}
// Pushes an array onto a heap allocated array of size_t. Automatically
// allocates memory via realloc.  Final allocated array must be freed.
//
// Example:
// 		size_t push_idx   = 0;
// 		size_t *num_stack = NULL;
// 		BP_ArrayPushSizeT(0xcafebabe, &num_stack, &push_idx);
// 		BP_ArrayPushSizeT(0xdeadbeef, &num_stack, &push_idx);
//
//		bpfree(num_stack);
Pushes an array onto a heap allocated array of size_t. Automatically
allocates memory via realloc.  Final allocated array must be freed.




Pushes an array onto a heap allocated array of size_t . Automatically allocates memory via realloc . Final allocated array must be freed .
BP_ERROR_T BP_ArrayPushSizeT(size_t value, size_t ** stack, size_t *stack_n, P_BP_LINKL tq)
{
	if(!stack_n)
		return ERR_FAILURE;
	size_t new_stack_size = (*stack_n+1) * sizeof(size_t);
	if(!tq)
		stack[0] = (size_t *) bprealloc(*stack, new_stack_size);
	else
		stack[0] = (size_t *) tq_realloc(tq, *stack, new_stack_size, BPLN);
	stack[0][*stack_n] = value;
	*stack_n = *stack_n + 1;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_ArrayPushSizeT ( size_t value , size_t * * stack , size_t * stack_n , P_BP_LINKL tq ) { if ( ! stack_n ) return ERR_FAILURE ; size_t new_stack_size = ( * stack_n + 1 ) * sizeof ( size_t ) ; if ( ! tq ) stack [ 0 ] = ( size_t * ) bprealloc ( * stack , new_stack_size ) ; else stack [ 0 ] = ( size_t * ) tq_realloc ( tq , * stack , new_stack_size , BPLN ) ; stack [ 0 ] [ * stack_n ] = value ; * stack_n = * stack_n + 1 ; return ERR_SUCCESS ; }
Pushes an array onto a heap allocated array of size_t.
Pushes an array onto a heap allocated array of size_t .
// ensure we have a pointer to the stack // calculate the new stack size based on provided inputs // create new stack // set the value in the gadget stack // increment the stack counter // return indicating success