Annotation of 43BSD/contrib/nntp/xmit/llist.c, revision 1.1

1.1     ! root        1: #include "llist.h"
        !             2: 
        !             3: extern void    free();
        !             4: extern caddr_t malloc();
        !             5: 
        !             6: #define        align(x)        ((x) + ((x) % sizeof(long)))
        !             7: 
        !             8: /*
        !             9: ** recursively free a linked list
        !            10: */
        !            11: void
        !            12: l_free(lp)
        !            13: register struct llist *lp;
        !            14: {
        !            15:        if (lp->l_next == NULL)
        !            16:                return;
        !            17:        l_free(lp->l_next);
        !            18:        free(lp->l_item);
        !            19: }
        !            20: 
        !            21: /*
        !            22: ** allocate a new element in a linked list, along with enough space
        !            23: ** at the end of the item for the next list element header.
        !            24: */
        !            25: struct llist *
        !            26: l_alloc(lp, s, len)
        !            27: register struct llist  *lp;
        !            28: caddr_t        *s;
        !            29: register unsigned len;
        !            30: {
        !            31:        if (s == NULL || lp == NULL)
        !            32:                return(NULL);
        !            33: 
        !            34:        lp->l_len = len;
        !            35:        len = align(len);
        !            36: 
        !            37:        if ((lp->l_item = malloc(len + sizeof(struct llist))) == NULL)
        !            38:                return(NULL);
        !            39: 
        !            40:        bcopy(s, lp->l_item, len);
        !            41:        lp->l_next = (struct llist *)(&lp->l_item[len]);
        !            42: 
        !            43:        /*
        !            44:        ** set up next list entry
        !            45:        */
        !            46:        lp = lp->l_next;
        !            47:        lp->l_next = NULL;
        !            48:        lp->l_item = NULL;
        !            49:        lp->l_len = 0;
        !            50:        return(lp);
        !            51: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.