ObjectType structure <BLOC/object.h>
The ObjectType structure describes a type of object that will be serviced by the library. Once created it should not be modified.
Syntax
struct ObjectType { refcount_t usage; const char *name; size_t size; unsigned int cache; void (*new)(void *); void (*delete)(void *); };
Members
usage
A count of the total number of objects of this type instantiated. This member should never be altered or declared by any program, and is entirely managed by the library.
name
The name that can be used to identify the object type, to aid debugging and logging. This value can be anything, since it helps the programmer, and is never used by the library.
size
The number of bytes that must be allocated for each object of this type. This value is used by the library when creating new instances of an object type.
cache
The number of objects of this type that should be held the type's cache. When objects of this type are deleted, the memory they occupy will be given to a cache for faster allocations. If this value is zero then no objects will be held in reserve.
new
The function to be called when a new object of this type is created. The function will be passed a pointer to the new object. This function runs before the caller receives the object.
delete
The function to be called when an object of this type is deleted. This will be passed a pointer to the object and is called when the last reference to the object is dropped. It should perform the opposite of the new function, and release any resources the object may be holding.