Ignore:
Timestamp:
04/10/14 01:24:05 (9 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:
df668eb
Parents:
fb1fd42
Message:

Use size_t rather than int for the data structures. Export vector, deque and ring_buffer for testing and use in programs.
Remove some inlines for now since these result in lots of compile warnings when also exported, the compiler is probably smart enough anyway.

File:
1 edited

Legend:

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

    rd6a56b6 read9478  
    1919};
    2020
    21 void libtrace_deque_init(libtrace_queue_t * q, int element_size)
     21DLLEXPORT void libtrace_deque_init(libtrace_queue_t * q, size_t element_size)
    2222{
    2323        q->head = NULL;
     
    2525        q->size = 0;
    2626        q->element_size = element_size;
    27 //      q->max_size;
    2827        assert(pthread_mutex_init(&q->lock, NULL) == 0);
    2928}
    3029
    31 inline void libtrace_deque_push_back(libtrace_queue_t *q, void *d)
     30DLLEXPORT void libtrace_deque_push_back(libtrace_queue_t *q, void *d)
    3231{
    3332        // Do as much work as possible outside the lock
     
    5251}
    5352
    54 inline void libtrace_deque_push_front(libtrace_queue_t *q, void *d)
     53DLLEXPORT void libtrace_deque_push_front(libtrace_queue_t *q, void *d)
    5554{
    5655        // Do as much work as possible outside the lock
     
    7675}
    7776
    78 inline int libtrace_deque_peek_front(libtrace_queue_t *q, void *d)
     77DLLEXPORT int libtrace_deque_peek_front(libtrace_queue_t *q, void *d)
    7978{
    8079        int ret = 1;
     
    8887}
    8988
    90 inline int libtrace_deque_peek_tail(libtrace_queue_t *q, void *d)
     89DLLEXPORT int libtrace_deque_peek_tail(libtrace_queue_t *q, void *d)
    9190{
    9291        int ret = 1;
     
    10099}
    101100
    102 inline int libtrace_deque_pop_front(libtrace_queue_t *q, void *d)
     101DLLEXPORT int libtrace_deque_pop_front(libtrace_queue_t *q, void *d)
    103102{
    104103        int ret = 0;
     
    124123}
    125124
    126 inline int libtrace_deque_pop_tail(libtrace_queue_t *q, void *d)
     125DLLEXPORT int libtrace_deque_pop_tail(libtrace_queue_t *q, void *d)
    127126{
    128127        int ret = 0;
     
    133132                ret = 1;
    134133                q->tail = n->prev;
    135                 if(q->tail)
     134                if (q->tail)
    136135                        q->tail->next = NULL;
    137136                q->size--;
     
    140139        }
    141140        assert(pthread_mutex_unlock(&q->lock) == 0);
    142         memcpy(d, &q->tail->data, q->element_size);
    143         free(n);
     141        if (ret) {
     142                memcpy(d, &n->data, q->element_size);
     143                free(n);
     144        }
    144145        return ret;
    145146}
    146147
    147 inline int libtrace_deque_get_size(libtrace_queue_t *q)
     148DLLEXPORT size_t libtrace_deque_get_size(libtrace_queue_t *q)
    148149{
    149150#if RACE_SAFE
    150         int ret;
     151        size_t ret;
    151152        assert(pthread_mutex_lock(&q->lock) == 0);
    152153        ret = q->size;
     
    158159}
    159160
    160 inline void libtrace_zero_deque(libtrace_queue_t *q)
     161DLLEXPORT void libtrace_zero_deque(libtrace_queue_t *q)
    161162{
    162163        q->head = q->tail = NULL;
Note: See TracChangeset for help on using the changeset viewer.