Modules | |
| The Cache Interface | |
Typedefs | |
| typedef Cmaid_Container | Cmaid_Cache |
| Type definition of the Cache Class. | |
Functions | |
| CMAID_INLINE void * | cmaid_cache_instance (Cmaid_Cache *s, const void *data) |
| Caches an object for reuse. | |
| CMAID_INLINE void | cmaid_cache_release (Cmaid_Cache *s, const void *data) |
| Decrease the reference count of the given object. | |
The cache class provides an interface to reuse objects to reduce overall memory usage. The cache is intended to be used for (large) constant arrays or structures that are used in many place at the same time. Instead of having an allocated copy of the object, the cache gives the opportunity to share them, and to have only one copy of them. This can reduce the overall memory usage. Keep in mind that this only works if the objects are not unique.
Since the cache interface is inheriting from the container interface, you can use all available container functions for it to.
| CMAID_INLINE void* cmaid_cache_instance | ( | Cmaid_Cache * | s, | |
| const void * | data | |||
| ) |
Caches an object for reuse.
| s | The cache to get an instance | |
| data | The object to cache |
| CMAID_INLINE void cmaid_cache_release | ( | Cmaid_Cache * | s, | |
| const void * | data | |||
| ) |
Decrease the reference count of the given object.
| s | The cache to release an instance | |
| data | The object to be released |
1.5.8