src/libs/elektra/opmphm_vstack.c
/**
 * Pops an element from the Vstack and resizes the stack if needed.
 *
 * @ingroup vstack
 * @retval the element
 * @retval NULL on empty or error
 */
Pops an element from the Vstack and resizes the stack if needed.
@ingroup vstack
@retval the element
@retval NULL on empty or error
Pops an element from the Vstack and resizes the stack if needed . @ingroup vstack @retval the element @retval NULL on empty or error
void * elektraVstackPop (Vstack * stack)
{
	if (!stack) return NULL;
	if (elektraVstackIsEmpty (stack)) return NULL;
	--stack->head;
	if (stack->size > stack->minSize && (size_t) (stack->head - stack->data) <= stack->size >> 2)
	{
		stack->size >>= 1;
		ELEKTRA_LOG_DEBUG ("VSTACK REALLOC TO = %zu", stack->size);
		int diff = stack->head - stack->data;
		if (elektraRealloc ((void **)&stack->data, stack->size * sizeof (void *)) == -1)
		{
			++stack->head;
			stack->size <<= 1;
			return NULL;
		}
		stack->head = stack->data + diff;
	}
	return *stack->head;
}
void * elektraVstackPop ( Vstack * stack ) { if ( ! stack ) return NULL ; if ( elektraVstackIsEmpty ( stack ) ) return NULL ; -- stack -> head ; if ( stack -> size > stack -> minSize && ( size_t ) ( stack -> head - stack -> data ) <= stack -> size >> 2 ) { stack -> size >>= 1 ; ELEKTRA_LOG_DEBUG ( " " , stack -> size ) ; int diff = stack -> head - stack -> data ; if ( elektraRealloc ( ( void * * ) & stack -> data , stack -> size * sizeof ( void * ) ) == -1 ) { ++ stack -> head ; stack -> size <<= 1 ; return NULL ; } stack -> head = stack -> data + diff ; } return * stack -> head ; }
Pops an element from the Vstack and resizes the stack if needed.
Pops an element from the Vstack and resizes the stack if needed .
// shrink