Changeset fed9152 for lib/data-struct/object_cache.c
- Timestamp:
- 01/20/15 10:52:15 (8 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 1b59edf, cb39d35
- Parents:
- 18bf317 (diff), 04bf7c5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/data-struct/object_cache.c
r6e41e73 r04bf7c5 175 175 * reads will block (free never should).Otherwise packets can be freely 176 176 * allocated upon requested and are free'd if there is not enough space for them. 177 * @return Returns The number of packets outstanding, or extra object recevied 178 * Ideally this should be zero (0) otherwise some form of memory leak 179 * is likely present. 177 * @return If successful returns 0 otherwise -1. 180 178 */ 181 DLLEXPORT void libtrace_ocache_init(libtrace_ocache_t *oc, void *(*alloc)(void), void (*free)(void *), 182 size_t thread_cache_size, size_t buffer_size, bool limit_size) { 179 DLLEXPORT int libtrace_ocache_init(libtrace_ocache_t *oc, void *(*alloc)(void), 180 void (*free)(void *), 181 size_t thread_cache_size, 182 size_t buffer_size, bool limit_size) { 183 183 184 184 assert(buffer_size); 185 185 assert(alloc); 186 186 assert(free); 187 libtrace_ringbuffer_init(&oc->rb, buffer_size, LIBTRACE_RINGBUFFER_BLOCKING); 187 if (libtrace_ringbuffer_init(&oc->rb, buffer_size, LIBTRACE_RINGBUFFER_BLOCKING) != 0) { 188 return -1; 189 } 188 190 oc->alloc = alloc; 189 191 oc->free = free; … … 193 195 oc->max_nb_thread_list = 0x10; 194 196 oc->thread_list = calloc(0x10, sizeof(void*)); 197 if (oc->thread_list == NULL) { 198 libtrace_ringbuffer_destroy(&oc->rb); 199 return -1; 200 } 195 201 pthread_spin_init(&oc->spin, 0); 196 202 if (limit_size) … … 198 204 else 199 205 oc->max_allocations = 0; 206 return 0; 200 207 } 201 208
Note: See TracChangeset
for help on using the changeset viewer.