From 448021e7e1e60544abadb9cb609e6fc541697352 Mon Sep 17 00:00:00 2001 From: James McKaskill Date: Thu, 12 Sep 2013 14:42:30 -0400 Subject: [PATCH] use create_local --- capn-malloc.c | 5 +++++ capn.c | 2 +- capn.h | 4 +--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/capn-malloc.c b/capn-malloc.c index 8a8dcc8..e1379c4 100644 --- a/capn-malloc.c +++ b/capn-malloc.c @@ -23,9 +23,14 @@ static struct capn_segment *create(void *u, uint32_t id, int sz) { return s; } +static struct capn_segment *create_local(void *u, int sz) { + return create(u, 0, sz); +} + void capn_init_malloc(struct capn *c) { memset(c, 0, sizeof(*c)); c->create = &create; + c->create_local = &create_local; } void capn_free(struct capn *c) { diff --git a/capn.c b/capn.c index 3023467..2b27c9c 100644 --- a/capn.c +++ b/capn.c @@ -662,7 +662,7 @@ static int copy_ptr(struct capn_segment *seg, char *data, struct capn_ptr *t, st /* need to allocate a struct copy */ if (!cs || cs->len + sizeof(*n) > cs->cap) { - cs = c->create ? c->create(c->user, CAPN_SEGID_LOCAL, sizeof(*n)) : NULL; + cs = c->create_local ? c->create_local(c->user, sizeof(*n)) : NULL; if (!cs) { /* can't allocate a copy structure */ return -1; diff --git a/capn.h b/capn.h index ec2845e..80f0ff5 100644 --- a/capn.h +++ b/capn.h @@ -10,8 +10,6 @@ extern "C" { #endif -#define CAPN_SEGID_LOCAL 0xFFFFFFFF - #if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) #define CAPN_INLINE static inline #else @@ -44,7 +42,7 @@ struct capn { /* user settable */ struct capn_segment *(*lookup)(void* /*user*/, uint32_t /*id */); struct capn_segment *(*create)(void* /*user*/, uint32_t /*id */, int /*sz*/); - struct capn_segment *(*create_local)(void* /*user*/, uint32_t /*id */, int /*sz*/); + struct capn_segment *(*create_local)(void* /*user*/, int /*sz*/); void *user; /* zero initialized, user should not modify */ uint32_t segnum;