Esempio n. 1
0
File: attr.c Progetto: bgraves/dowse
// TODO: split this in two functions: one to retrieve attr and one to
// strcat contents into it.
void attrcatn(attrlist_t al, const char *name, const _char *value, size_t len) {
    attr_t *at;
    size_t oldlen;
    _char *newvalue;
    at = setup_access(al, name);

    /* a null value would delete the attribute */
    if(value==NULL) {
        if(at) attrdel(al, at); /* delete if there is no value */
        return;
    }

    /* append the string */
    oldlen = at->len;

    // kore_log(LOG_DEBUG,"attr realloc from %u to %u for value: %s",
    //          oldlen, oldlen+len+1, value);

    newvalue = kore_realloc(at->value, oldlen+len+1);
    if(!newvalue) {
        kore_log(LOG_ERR,"attrcatn realloc to size %u",
                 oldlen+len+1);
        return; }

    at->len = oldlen+len+1;
    strncat(newvalue,value,len);
    at->value=newvalue;
}
Esempio n. 2
0
void
kore_buf_append(struct kore_buf *buf, const void *d, u_int32_t len)
{
	if ((buf->offset + len) >= buf->length) {
		buf->length += len + KORE_BUF_INCREMENT;
		buf->data = kore_realloc(buf->data, buf->length);
	}

	memcpy((buf->data + buf->offset), d, len);
	buf->offset += len;
}
Esempio n. 3
0
File: attr.c Progetto: bgraves/dowse
static attr_t *attradd(attrlist_t al, int type)
{
    attr_t *at;

    al->data=kore_realloc(al->data, (al->len+1)*sizeof *al->data);
    at=al->data+al->len;
    al->len++;
    at->type=type;
    at->len=0;
    at->value=NULL;
    return at;
}
Esempio n. 4
0
File: attr.c Progetto: bgraves/dowse
static int nameadd(const char *name)
{
    _char **entry;
    int type;

    if(!name) abort();
    name_list.data=kore_realloc(name_list.data, (name_list.len+1)*sizeof *name_list.data);
    type=name_list.len;
    entry=name_list.data+type;
    name_list.len++;
    *entry=(_char*)kore_strdup((const char*)name);
    return type;
}
Esempio n. 5
0
File: net.c Progetto: jdiego/kore
void
net_recv_expand(struct connection *c, u_int32_t len, int (*cb)(struct netbuf *))
{
	kore_debug("net_recv_expand(): %p %d", c, len);

	if (c->rnb->type != NETBUF_RECV)
		fatal("net_recv_expand(): wrong netbuf type");

	c->rnb->cb = cb;
	c->rnb->b_len += len;
	c->rnb->m_len = c->rnb->b_len;
	c->rnb->buf = kore_realloc(c->rnb->buf, c->rnb->b_len);
}
Esempio n. 6
0
File: buf.c Progetto: SDAIA/kore
void
kore_buf_append(struct kore_buf *buf, const void *d, size_t len)
{
	if ((buf->offset + len) < len)
		fatal("overflow in kore_buf_append");

	if ((buf->offset + len) > buf->length) {
		buf->length += len;
		buf->data = kore_realloc(buf->data, buf->length);
	}

	memcpy((buf->data + buf->offset), d, len);
	buf->offset += len;
}