Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -91,16 +91,49 @@ * \param nitems The number of items to remove */ - removeNItems: (size_t)nitems; @end +/** + * The OFBigArray class is nearly the same as the OFArray class, but it + * allocates the memory rather in pages than in bytes. + * This is faster, but needs more memory. It is especially useful if you want + * to store large hunks of data. + */ @interface OFBigArray: OFArray { size_t size; } +/** + * Creates a new OFBigArray whose items all have the same size. + * + * \param is The size of each element in the OFBigArray + * \return A new allocated and initialized OFBigArray + */ + newWithItemSize: (size_t)is; + +/** + * Initializes an already allocated OFBigArray whose items all have the same + * size. + * + * \param is The size of each element in the OFBigArray + * \return An initialized OFBigArray + */ - initWithItemSize: (size_t)is; + +/** + * Adds items from a C array to the OFBigArray + * + * \param nitems The number of items to add + * \param carray A C array containing the items to add + */ - addNItems: (size_t)nitems fromCArray: (void*)carray; + +/** + * Removes the last items from the OFBigArray + * + * \param nitems The number of items to remove + */ - removeNItems: (size_t)nitems; @end Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -16,22 +16,74 @@ void *ptr; struct __ofobject_allocated_mem *prev; struct __ofobject_allocated_mem *next; }; +/** + * The OFObject class is the base class for all other classes inside ObjFW. + */ @interface OFObject: Object { struct __ofobject_allocated_mem *__mem_pool; } +/** + * Initialize the already allocated object. + * Also sets up the memory pool for the object. + * + * \return An initialized object + */ - init; + +/** + * Allocate memory and store it in the objects memory pool so it can be free'd + * automatically when the object is free'd. + * + * \param size The size of the memory to allocate + * \return A pointer to the allocated memory + */ - (void*)getMemWithSize: (size_t)size; + +/** + * Allocate memory for a specified number of items and store it in the objects + * memory pool so it can be free'd automatically when the object is free'd. + * + * \param nitems The number of items to allocate + * \param size The size of each item to allocate + * \return A pointer to the allocated memory + */ - (void*)getMemForNItems: (size_t)nitems ofSize: (size_t)size; + +/** + * Resize memory in the memory pool to a specified size. + * + * \param size The new size for the memory chunk + * \return A pointer to the resized memory chunk + */ - (void*)resizeMem: (void*)ptr toSize: (size_t)size; + +/** + * Resize memory in the memory pool to a specific number of items of a + * specified size. + * + * \param nitems The number of items to resize to + * \param size The size of each item to resize to + * \return A pointer to the resized memory chunk + */ - (void*)resizeMem: (void*)ptr toNItems: (size_t)nitems ofSize: (size_t)size; + +/** + * Frees allocated memory and removes it from the memory pool. + * + * \param ptr A pointer to the allocated memory + */ - freeMem: (void*)ptr; + +/** + * Frees the object and also frees all memory allocated via its memory pool. + */ - free; @end