Changeset 26416 in vbox for trunk/include
- Timestamp:
- Feb 10, 2010 4:32:22 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57519
- Location:
- trunk/include/iprt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/err.h
r26369 r26416 1205 1205 /** @} */ 1206 1206 1207 /** @name RTMemCache status codes 1208 * @{ */ 1209 /** Reached the max cache size. */ 1210 #define VERR_MEM_CACHE_MAX_SIZE (-855) 1211 /** @} */ 1212 1207 1213 /** @name RTS3 status codes 1208 1214 * @{ */ -
trunk/include/iprt/memcache.h
r26341 r26416 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Sun Microsystems, Inc.6 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 */ 48 48 49 /** @todo Specify and implement RTMemCache. (This header is just a reminder.) */ 49 /** A memory cache handle. */ 50 typedef R3R0PTRTYPE(struct RTMEMCACHEINT *) RTMEMCACHE; 51 /** Pointer to a memory cache handle. */ 52 typedef RTMEMCACHE *PRTMEMCACHE; 53 /** Nil memory cache handle. */ 54 #define NIL_RTMEMCACHE ((RTMEMCACHE)0) 50 55 56 57 /** 58 * Object constructor. 59 * 60 * This is called for when an element is allocated for the first time. 61 * 62 * @returns IPRT status code. 63 * @param hMemCache The cache handle. 64 * @param pvObj The memory object that should be initialized. 65 * @param pvUser The user argument. 66 * 67 * @remarks No serialization is performed. 68 */ 69 typedef DECLCALLBACK(int) FNMEMCACHECTOR(RTMEMCACHE hMemCache, void *pvObj, void *pvUser); 70 /** Pointer to an object constructor for the memory cache. */ 71 typedef FNMEMCACHECTOR *PFNMEMCACHECTOR; 72 73 /** 74 * Object destructor. 75 * 76 * This is called when we're shrinking or destroying the cache. 77 * 78 * @param hMemCache The cache handle. 79 * @param pvObj The memory object that should be initialized. 80 * @param pvUser The user argument. 81 * 82 * @remarks No serialization is performed. 83 */ 84 typedef DECLCALLBACK(void) FNMEMCACHEDTOR(RTMEMCACHE hMemCache, void *pvObj, void *pvUser); 85 /** Pointer to an object destructor for the memory cache. */ 86 typedef FNMEMCACHEDTOR *PFNMEMCACHEDTOR; 87 88 89 /** 90 * Create an allocation cache for fixed size memory objects. 91 * 92 * @returns IPRT status code. 93 * @param phMemCache Where to return the cache handle. 94 * @param cbObject The size of one memory object. 95 * @param cbAlignment The object alignment. This must be a power of 96 * two. The higest alignment is 64. If set to 0, 97 * a sensible alignment value will be derived from 98 * the object size. 99 * @param cMaxObjects The maximum cache size. Pass UINT32_MAX if unsure. 100 * @param pfnCtor Object constructor callback. Optional. 101 * @param pfnDtor Object destructor callback. Optional. 102 * @param pvUser User argument for the two callbacks. 103 */ 104 RTDECL(int) RTMemCacheCreate(PRTMEMCACHE phMemCache, size_t cbObject, uint32_t cMaxObjects, 105 PFNMEMCACHECTOR pfnCtor, PFNMEMCACHEDTOR pfnDtor, void *pvUser); 106 107 /** 108 * Destroy a cache destroying and freeing allocated memory. 109 * 110 * @returns IPRT status code. 111 * @param hMemCache The cache handle. NIL is quietly (VINF_SUCCESS) 112 * ignored. 113 */ 114 RTDECL(int) RTMemCacheDestroy(RTMEMCACHE hMemCache); 115 116 /** 117 * Allocate an object. 118 * 119 * @returns Pointer to the allocated cache object. 120 * @param hMemCache The cache handle. 121 */ 122 RTDECL(void *) RTMemCacheAlloc(RTMEMCACHE hMemCache); 123 124 /** 125 * Allocate an object and return a proper status code. 126 * 127 * @returns IPRT status code. 128 * @retval VERR_MEM_CACHE_MAX_SIZE if we've reached maximum size (see 129 * RTMemCacheCreate). 130 * @retval VERR_NO_MEMORY if we failed to allocate more memory for the cache. 131 * 132 * @param hMemCache The cache handle. 133 * @param ppvObj Where to return the object. 134 */ 135 RTDECL(int) RTMemCacheAllocEx(RTMEMCACHE hMemCache, void **ppvObj); 136 137 /** 138 * Free an object previously returned by RTMemCacheAlloc or RTMemCacheAllocEx. 139 * 140 * @param hMemCache The cache handle. 141 * @param pvObj The object to free. NULL is fine. 142 */ 143 RTDECL(void) RTMemCacheFree(RTMEMCACHE hMemCache, void *pvObj); 51 144 52 145 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.