struct bcm_tlvbuf *
bcm_xtlv_buf_alloc(void *osh, uint16 len)
{
	struct bcm_tlvbuf *tbuf = MALLOCZ(osh, sizeof(struct bcm_tlvbuf) + len);
	if (tbuf == NULL) {
		return NULL;
	}
	tbuf->size = len;
	tbuf->head = tbuf->buf = (uint8 *)(tbuf + 1);
	return tbuf;
}
Exemplo n.º 2
0
struct DemoLib *dlCreate(const char *name, int startValue, int burst)
{
    struct DemoLib *res;
    MALLOCZ(res, sizeof(struct DemoLib));
    res->name = strdup(name);
    res->startValue = startValue;
    res->burst = burst;
    MALLOCZ(res->values, sizeof(struct DemoFifo));
    MALLOCZ(res->pool, sizeof(struct DemoFifo));
    pthread_mutex_init(&res->values->mutex, NULL);
    pthread_mutex_init(&res->pool->mutex, NULL);
    TAILQ_INIT(&res->values->head);
    TAILQ_INIT(&res->pool->head);
    int i=0;
    for (;i<res->burst;++i) {
        struct DemoItem *di;
        MALLOCZ(di, sizeof(struct DemoItem));
        push(res->pool, di);
    }

    return res;
}