/** * array-stack.c * An implementation of linear structures using array-based stacks. */ // +---------+-------------------------------------------------------- // | Headers | // +---------+ #include "collection.h" #include // For malloc #include // For strdup // +-----------+------------------------------------------------------ // | Constants | // +-----------+ #ifndef STACK_CAPACITY #define STACK_CAPACITY 100 #endif // STACK_CAPACITY // +-------+---------------------------------------------------------- // | Types | // +-------+ struct collection { char *contents[STACK_CAPACITY]; int top; }; // +-----------+------------------------------------------------------ // | Functions | // +-----------+ struct collection * new_collection (int recommended_capacity) { struct collection *result; result = malloc (sizeof (struct collection)); if (result == NULL) return NULL; return result; } // new_collection void collection_free (struct collection *stuff) { while (! collection_is_empty (stuff)) free (collection_get (stuff)); free (stuff); } // collection_free int collection_put (struct collection *stuff, char *str) { return 1; } // collection_put char * collection_get (struct collection *stuff) { return NULL; } // collection_get char * collection_peek (struct collection *stuff) { return NULL; } // collection_peek int collection_size (struct collection *stuff) { return 0; } // collection_size int collection_is_empty (struct collection *stuff) { return 0; } // collection_is_empty int collection_is_full (struct collection *stuff) { return 0; } // collection_is_full