forked from mirrors/kore
Change kore_buf_appendv() to take a va_list
This commit is contained in:
parent
d2618db525
commit
39dd9d7972
|
@ -280,11 +280,6 @@ struct kore_buf {
|
||||||
u_int64_t offset;
|
u_int64_t offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct buf_vec {
|
|
||||||
u_int8_t *data;
|
|
||||||
u_int32_t length;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct kore_pool_region {
|
struct kore_pool_region {
|
||||||
void *start;
|
void *start;
|
||||||
LIST_ENTRY(kore_pool_region) list;
|
LIST_ENTRY(kore_pool_region) list;
|
||||||
|
@ -455,7 +450,7 @@ struct kore_buf *kore_buf_create(u_int32_t);
|
||||||
void kore_buf_append(struct kore_buf *, void *, u_int32_t);
|
void kore_buf_append(struct kore_buf *, void *, u_int32_t);
|
||||||
u_int8_t *kore_buf_release(struct kore_buf *, u_int32_t *);
|
u_int8_t *kore_buf_release(struct kore_buf *, u_int32_t *);
|
||||||
void kore_buf_appendf(struct kore_buf *, const char *, ...);
|
void kore_buf_appendf(struct kore_buf *, const char *, ...);
|
||||||
void kore_buf_appendv(struct kore_buf *, struct buf_vec *, u_int16_t);
|
void kore_buf_appendv(struct kore_buf *, const char *, va_list);
|
||||||
void kore_buf_appendb(struct kore_buf *, struct kore_buf *);
|
void kore_buf_appendb(struct kore_buf *, struct kore_buf *);
|
||||||
void kore_buf_replace_string(struct kore_buf *, char *, void *, size_t);
|
void kore_buf_replace_string(struct kore_buf *, char *, void *, size_t);
|
||||||
|
|
||||||
|
|
21
src/buf.c
21
src/buf.c
|
@ -53,29 +53,26 @@ kore_buf_appendb(struct kore_buf *buf, struct kore_buf *src)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kore_buf_appendv(struct kore_buf *buf, struct buf_vec *v, u_int16_t count)
|
kore_buf_appendv(struct kore_buf *buf, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
u_int16_t i;
|
int l;
|
||||||
struct buf_vec *p;
|
char b[4096];
|
||||||
|
|
||||||
p = v;
|
l = vsnprintf(b, sizeof(b), fmt, args);
|
||||||
for (i = 0; i < count; i++) {
|
if (l == -1 || (size_t)l >= sizeof(b))
|
||||||
kore_buf_append(buf, p->data, p->length);
|
fatal("kore_buf_appendv(): error or truncation");
|
||||||
p++;
|
|
||||||
}
|
kore_buf_append(buf, (u_int8_t *)b, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kore_buf_appendf(struct kore_buf *buf, const char *fmt, ...)
|
kore_buf_appendf(struct kore_buf *buf, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char b[2048];
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(b, sizeof(b), fmt, args);
|
kore_buf_appendv(buf, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
kore_buf_append(buf, (u_int8_t *)b, strlen(b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int8_t *
|
u_int8_t *
|
||||||
|
|
Loading…
Reference in New Issue