diff options
author | Mark Hindley <mark@hindley.org.uk> | 2018-11-12 09:22:09 +0000 |
---|---|---|
committer | Mark Hindley <mark@hindley.org.uk> | 2018-11-12 09:22:09 +0000 |
commit | a7bee29ae34de50a86bf64d4ea9f69bdbc3b27e4 (patch) | |
tree | ac6c9abfefdc4286c4f52167738c4e4d35c96cd4 /src/basic/alloc-util.h | |
parent | 98f0f1042d219289b880436fad42823433648d18 (diff) | |
parent | 2cc17d30309a1db16cccbf376a59ae40e47b6959 (diff) |
Merge branch 'merge_upstream' into debian_WIP
Diffstat (limited to 'src/basic/alloc-util.h')
-rw-r--r-- | src/basic/alloc-util.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h index ebe42889e..2a6deb12c 100644 --- a/src/basic/alloc-util.h +++ b/src/basic/alloc-util.h @@ -46,6 +46,21 @@ static inline void *mfree(void *memory) { void* memdup(const void *p, size_t l) _alloc_(2); void* memdup_suffix0(const void *p, size_t l) _alloc_(2); +#define memdupa(p, l) \ + ({ \ + void *_q_; \ + _q_ = alloca(l); \ + memcpy(_q_, p, l); \ + }) + +#define memdupa_suffix0(p, l) \ + ({ \ + void *_q_; \ + _q_ = alloca(l + 1); \ + ((uint8_t*) _q_)[l] = 0; \ + memcpy(_q_, p, l); \ + }) + static inline void freep(void *p) { free(*(void**) p); } |