biglist_t*
biglist_insert_sorted(biglist_t* bl, void* data, biglist_compare_f cmp)
{
    /** @todo Use a linear time algorithm */
    bl = biglist_prepend(bl, data);
    return biglist_sort(bl, cmp);
}
示例#2
0
static int insert__(bighash_table_t *table, int count, biglist_t** entries)
{
    int c;
    for(c = 0; c < count; c++) {
        test_entry_t *te = aim_zmalloc(sizeof(*te));
        te->id = c;

        bighash_insert(table, &te->hash_entry, hash_id(te->id));
        if(entries) {
            *entries = biglist_prepend(*entries, te);
        }
        /** Make sure we can find it */
        test_entry_t *fe = find_by_id(table, te->id);
        if(fe == NULL) {
            AIM_DIE("inserted entry was not found, count=%d/%d", c, count);
        }
        if(fe != te) {
            AIM_DIE("Retreived pointer not equal.");
        }
        if(bighash_entry_count(table) != (c+1)) {
            AIM_DIE("Entry count mismatch: should be %d, reported as %d",
                    (c+1), bighash_entry_count(table));
        }
    }
    return 0;
}
示例#3
0
int
biglist_locked_prepend(biglist_locked_t* bl, void* data)
{
    biglist_lock(bl);
    bl->list = biglist_prepend(bl->list, data);
    biglist_unlock(bl);
    return 0;
}
biglist_t*
biglist_from_data_array(void** data, int size)
{
    int i;
    biglist_t* rv = NULL;
    if((data == NULL) || (size <= 0)) {
        return NULL;
    }
    for(i = size-1; i >= 0; i--) {
        rv = biglist_prepend(rv, data[i]);
    }
    return rv;
}
示例#5
0
void
of_object_track(of_object_t *obj, const char *file, int line)
{
    if (obj != NULL) {
        LOCI_LOG_TRACE("OF obj track %p, wire buf %p\n%s:%d\\n",
                       obj, obj->wire_object.wbuf, file, line);
        obj->track_info.file = file;
        obj->track_info.line = line;
        TRACK_OBJS = biglist_prepend(TRACK_OBJS, (void *)obj);
        obj->track_info.bl_entry = TRACK_OBJS;
        obj->track_info.magic = OF_OBJECT_TRACKING_MAGIC;

        TRACK->allocs += 1;
        TRACK->count_current += 1;
        CHECK_MAX(TRACK->count_current, TRACK->count_max);
    }
}