src/libmetha/utable.c
url_t *
lm_ulist_inc(ulist_t *ul)
{
    int x;

    if (!ul->cap) {
        ul->sz = 0;
        ul->cap = ULIST_DEFAULT_PREALLOC;
        if (!(ul->row = malloc(ULIST_DEFAULT_PREALLOC*sizeof(url_t)))) {
            return 0;
        }
        for (x=0; x<ULIST_DEFAULT_PREALLOC; x++)
            lm_url_init(&ul->row[x]);
    }
    if (ul->sz >= ul->cap) {
        /* resize is necessary */
        ul->cap <<= 1;
        if (!(ul->row = realloc(ul->row, ul->cap*sizeof(url_t))))
            return 0;
        for (x=ul->sz; x<ul->cap; x++)
            lm_url_init(&ul->row[x]);
    }

    ul->sz++;
    return &ul->row[ul->sz-1];
}
/** 
 * Increase the size of the list and return a pointer
 * to the URL on the top, so that we can set it externally
 **/
Increase the size of the list and return a pointer
to the URL on the top, so that we can set it externally
Increase the size of the list and return a pointer to the URL on the top so that we can set it externally
url_t *
lm_ulist_inc(ulist_t *ul)
{
    int x;
    if (!ul->cap) {
        ul->sz = 0;
        ul->cap = ULIST_DEFAULT_PREALLOC;
        if (!(ul->row = malloc(ULIST_DEFAULT_PREALLOC*sizeof(url_t)))) {
            return 0;
        }
        for (x=0; x<ULIST_DEFAULT_PREALLOC; x++)
            lm_url_init(&ul->row[x]);
    }
    if (ul->sz >= ul->cap) {
        ul->cap <<= 1;
        if (!(ul->row = realloc(ul->row, ul->cap*sizeof(url_t))))
            return 0;
        for (x=ul->sz; x<ul->cap; x++)
            lm_url_init(&ul->row[x]);
    }
    ul->sz++;
    return &ul->row[ul->sz-1];
}
url_t * lm_ulist_inc ( ulist_t * ul ) { int x ; if ( ! ul -> cap ) { ul -> sz = 0 ; ul -> cap = ULIST_DEFAULT_PREALLOC ; if ( ! ( ul -> row = malloc ( ULIST_DEFAULT_PREALLOC * sizeof ( url_t ) ) ) ) { return 0 ; } for ( x = 0 ; x < ULIST_DEFAULT_PREALLOC ; x ++ ) lm_url_init ( & ul -> row [ x ] ) ; } if ( ul -> sz >= ul -> cap ) { ul -> cap <<= 1 ; if ( ! ( ul -> row = realloc ( ul -> row , ul -> cap * sizeof ( url_t ) ) ) ) return 0 ; for ( x = ul -> sz ; x < ul -> cap ; x ++ ) lm_url_init ( & ul -> row [ x ] ) ; } ul -> sz ++ ; return & ul -> row [ ul -> sz - 1 ] ; }
Increase the size of the list and return a pointer
 to the URL on the top, so that we can set it externally
Increase the size of the list and return a pointer to the URL on the top so that we can set it externally
/* resize is necessary */