Ignore:
Timestamp:
01/20/15 09:44:16 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
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:
75e088f, fed9152
Parents:
b73407f
Message:

Remove unused sliding window code.
Refactored pstart and added some proper error handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/data-struct/object_cache.c

    r6e41e73 r04bf7c5  
    175175  *             reads will block (free never should).Otherwise packets can be freely
    176176  *     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.
    180178  */
    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) {
     179DLLEXPORT 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) {
    183183
    184184        assert(buffer_size);
    185185        assert(alloc);
    186186        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        }
    188190        oc->alloc = alloc;
    189191        oc->free = free;
     
    193195        oc->max_nb_thread_list = 0x10;
    194196        oc->thread_list = calloc(0x10, sizeof(void*));
     197        if (oc->thread_list == NULL) {
     198                libtrace_ringbuffer_destroy(&oc->rb);
     199                return -1;
     200        }
    195201        pthread_spin_init(&oc->spin, 0);
    196202        if (limit_size)
     
    198204        else
    199205                oc->max_allocations = 0;
     206        return 0;
    200207}
    201208
Note: See TracChangeset for help on using the changeset viewer.