diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-03-31 16:16:37 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-03-31 16:16:37 +0200 |
commit | 392d5b378ceae5e1fd7c91ca545fcf4cd105744a (patch) | |
tree | e231fe77155323de76b535cd509ee5677f1bf28f /src/shared | |
parent | 11c4c2492083325531aeb3eeb9b041c929677890 (diff) |
bus: parse matches locally and allow registration of callbacks for them
This includes code to parse and split up match strings which will also
be useful to calculate bloom filter masks when the time comes.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.c | 17 | ||||
-rw-r--r-- | src/shared/util.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 873c95820a..760013c1fb 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -5855,3 +5855,20 @@ char *strrep(const char *s, unsigned n) { *p = 0; return r; } + +void* greedy_realloc(void **p, size_t *allocated, size_t need) { + size_t a; + void *q; + + if (*allocated >= need) + return *p; + + a = MAX(64, need * 2); + q = realloc(*p, a); + if (!q) + return NULL; + + *p = q; + *allocated = a; + return q; +} diff --git a/src/shared/util.h b/src/shared/util.h index 0d05cd6653..d1cdd901a0 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -613,3 +613,5 @@ void *unhexmem(const char *p, size_t l); char *strextend(char **x, ...); char *strrep(const char *s, unsigned n); + +void* greedy_realloc(void **p, size_t *allocated, size_t need); |