X-Git-Url: https://git.auder.net/?p=cgds.git;a=blobdiff_plain;f=src%2FStack.h;fp=src%2FStack.h;h=57bb6158658c1fd4e4fc3d37c178ed7c1a270980;hp=24ad176acd03535457d7b9dc14675a627bf6bb36;hb=e45132acdb58c076d5e06849fa51c26de9a7486d;hpb=1ff641f9960fa6c6081817a5641afb22fad91dcd diff --git a/src/Stack.h b/src/Stack.h index 24ad176..57bb615 100644 --- a/src/Stack.h +++ b/src/Stack.h @@ -15,23 +15,23 @@ * @brief Stack containing generic data. */ typedef struct Stack { - size_t dataSize; ///< Size in bytes of a stack element. - Vector* array; ///< Internal data structure: resizeable array. + size_t dataSize; ///< Size in bytes of a stack element. + Vector* array; ///< Internal data structure: resizeable array. } Stack; /** * @brief Initialize an empty stack. */ void _stack_init( - Stack* stack, ///< "this" pointer. - size_t dataSize ///< Size in bytes of a stack element. + Stack* stack, ///< "this" pointer. + size_t dataSize ///< Size in bytes of a stack element. ); /** * @brief Return an allocated and initialized stack. */ Stack* _stack_new( - size_t dataSize ///< Size in bytes of a stack element. + size_t dataSize ///< Size in bytes of a stack element. ); /** @@ -41,35 +41,37 @@ Stack* _stack_new( * Usage: Stack* stack_new( type) */ #define stack_new(type) \ - _stack_new(sizeof(type)) +{ \ + _stack_new(sizeof(type)); \ +} /** * @brief Copy constructor (shallow copy, ok for basic types). */ Stack* stack_copy( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Check if the stack is empty. */ bool stack_empty( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Return size of the current stack. */ UInt stack_size( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Add something on top of the stack. */ void _stack_push( - Stack* stack, ///< "this" pointer. - void* data ///< Data to be added. + Stack* stack, ///< "this" pointer. + void* data ///< Data to be added. ); /** @@ -81,15 +83,15 @@ void _stack_push( */ #define stack_push(stack, data) \ { \ - typeof((data)) tmp = data; \ - _stack_push(stack,&tmp); \ + typeof((data)) tmp = data; \ + _stack_push(stack,&tmp); \ } /** * @brief Return what is on top of the stack. */ void* _stack_top( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** @@ -101,29 +103,29 @@ void* _stack_top( */ #define stack_top(stack, data) \ { \ - void* pData = _stack_top(stack); \ - data = *((typeof(&data))pData); \ + void* pData = _stack_top(stack); \ + data = *((typeof(&data))pData); \ } /** * @brief Remove the top of the stack. */ void stack_pop( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Clear the entire stack. */ void stack_clear( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Destroy the stack: clear it, and free 'stack' pointer. */ void stack_destroy( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); #endif