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/ring_buffer.c

    ra49a9eb r04bf7c5  
    4747 *                              becomes available. LIBTRACE_RINGBUFFER_BLOCKING or LIBTRACE_RINGBUFFER_POLLING.
    4848 *                              NOTE: this mainly applies to the blocking functions
    49  */
    50 DLLEXPORT void libtrace_ringbuffer_init(libtrace_ringbuffer_t * rb, size_t size, int mode) {
     49 * @return If successful returns 0 otherwise -1 upon failure.
     50 */
     51DLLEXPORT int libtrace_ringbuffer_init(libtrace_ringbuffer_t * rb, size_t size, int mode) {
    5152        size = size + 1;
    52         assert (size > 1);
    53         rb->size = size; // Only this -1 actually usable :)
     53        if (!(size > 1))
     54                return -1;
     55        rb->size = size;
    5456        rb->start = 0;
    5557        rb->end = 0;
    5658        rb->elements = calloc(rb->size, sizeof(void*));
    57         assert(rb->elements);
     59        if (!rb->elements)
     60                return -1;
    5861        rb->mode = mode;
    5962        if (mode == LIBTRACE_RINGBUFFER_BLOCKING) {
    60                 /* The signaling part - i.e. release when data's ready to read */
     63                /* The signaling part - i.e. release when data is ready to read */
    6164                pthread_cond_init(&rb->full_cond, NULL);
    6265                pthread_cond_init(&rb->empty_cond, NULL);
     
    7578        ASSERT_RET(pthread_mutex_init(&rb->rlock, NULL), == 0);
    7679#endif
     80        return 0;
    7781}
    7882
Note: See TracChangeset for help on using the changeset viewer.