Annotation of embedaddon/lighttpd/src/joblist.c, revision 1.1

1.1     ! misho       1: #include "base.h"
        !             2: #include "joblist.h"
        !             3: #include "log.h"
        !             4: 
        !             5: #include <stdlib.h>
        !             6: #include <string.h>
        !             7: 
        !             8: int joblist_append(server *srv, connection *con) {
        !             9:        if (con->in_joblist) return 0;
        !            10: 
        !            11:        if (srv->joblist->size == 0) {
        !            12:                srv->joblist->size  = 16;
        !            13:                srv->joblist->ptr   = malloc(sizeof(*srv->joblist->ptr) * srv->joblist->size);
        !            14:        } else if (srv->joblist->used == srv->joblist->size) {
        !            15:                srv->joblist->size += 16;
        !            16:                srv->joblist->ptr   = realloc(srv->joblist->ptr, sizeof(*srv->joblist->ptr) * srv->joblist->size);
        !            17:        }
        !            18: 
        !            19:        srv->joblist->ptr[srv->joblist->used++] = con;
        !            20: 
        !            21:        return 0;
        !            22: }
        !            23: 
        !            24: void joblist_free(server *srv, connections *joblist) {
        !            25:        UNUSED(srv);
        !            26: 
        !            27:        free(joblist->ptr);
        !            28:        free(joblist);
        !            29: }
        !            30: 
        !            31: connection *fdwaitqueue_unshift(server *srv, connections *fdwaitqueue) {
        !            32:        connection *con;
        !            33:        UNUSED(srv);
        !            34: 
        !            35: 
        !            36:        if (fdwaitqueue->used == 0) return NULL;
        !            37: 
        !            38:        con = fdwaitqueue->ptr[0];
        !            39: 
        !            40:        memmove(fdwaitqueue->ptr, &(fdwaitqueue->ptr[1]), --fdwaitqueue->used * sizeof(*(fdwaitqueue->ptr)));
        !            41: 
        !            42:        return con;
        !            43: }
        !            44: 
        !            45: int fdwaitqueue_append(server *srv, connection *con) {
        !            46:        if (srv->fdwaitqueue->size == 0) {
        !            47:                srv->fdwaitqueue->size  = 16;
        !            48:                srv->fdwaitqueue->ptr   = malloc(sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size);
        !            49:        } else if (srv->fdwaitqueue->used == srv->fdwaitqueue->size) {
        !            50:                srv->fdwaitqueue->size += 16;
        !            51:                srv->fdwaitqueue->ptr   = realloc(srv->fdwaitqueue->ptr, sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size);
        !            52:        }
        !            53: 
        !            54:        srv->fdwaitqueue->ptr[srv->fdwaitqueue->used++] = con;
        !            55: 
        !            56:        return 0;
        !            57: }
        !            58: 
        !            59: void fdwaitqueue_free(server *srv, connections *fdwaitqueue) {
        !            60:        UNUSED(srv);
        !            61:        free(fdwaitqueue->ptr);
        !            62:        free(fdwaitqueue);
        !            63: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>