Giter VIP home page Giter VIP logo

queue's People

Contributors

tobithiel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

queue's Issues

queue_get returns incorrect value when no elements in queue

according to the doc , if you call queue_get on a queue with no elements, it should return > 0.

/**
 * get the first element of the queue
 *
 * q - the queue
 * e - pointer which will be set to the element
 *
 * returns 0 if everything worked, > 0 if no elements in queue, < 0 if error occured
 */
int8_t queue_get(queue_t *q, void **e);

It currently returns Q_ERR_NUM_ELEMENTS (-7) instead.

int8_t queue_get(queue_t *q, void **e) {
    *e = NULL;
    if (q == NULL)
        return Q_ERR_INVALID;
    if (0 != queue_lock_internal(q))
        return Q_ERR_LOCK;

    int8_t r = queue_get_internal(q, e, NULL, NULL, NULL);

    if (0 != queue_unlock_internal(q))
        return Q_ERR_LOCK;
    return r;
}

queue_get calls queue_get_internal which sets this here

int8_t queue_get_internal(queue_t *q, void **e, int (*action)(pthread_cond_t *, pthread_mutex_t *),
                          int (*cmp)(void *, void *), void *cmpel) {
    if (q == NULL) { // queue not valid
        *e = NULL;
        return Q_ERR_INVALID;
    }

    // are elements in the queue?
    if (q->num_els == 0) {
        if (action == NULL) {
            *e = NULL;
            return Q_ERR_NUM_ELEMENTS;  <------------- here
        } else {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.