mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-15 06:59:54 -05:00
project: merge mmsg meson.build file into mango meson.build
This commit is contained in:
parent
134242196e
commit
900397ab69
7 changed files with 32 additions and 283 deletions
30
mmsg/dynarr.h
Normal file
30
mmsg/dynarr.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef DYNARR_H__
|
||||
#define DYNARR_H__
|
||||
|
||||
#define DYNARR_DEF(t) \
|
||||
struct { \
|
||||
t *arr; \
|
||||
size_t len, cap, size; \
|
||||
}
|
||||
|
||||
#define DYNARR_INIT(p) \
|
||||
((p)->arr = reallocarray((p)->arr, ((p)->cap = 1), \
|
||||
((p)->size = sizeof(((p)->arr[0])))))
|
||||
|
||||
#define DYNARR_FINI(p) free((p)->arr)
|
||||
|
||||
#define DYNARR_PUSH(p, v) \
|
||||
do { \
|
||||
if ((p)->len >= (p)->cap) { \
|
||||
while ((p)->len >= ((p)->cap *= 2)) \
|
||||
; \
|
||||
(p)->arr = reallocarray((p)->arr, (p)->cap, (p)->size); \
|
||||
} \
|
||||
(p)->arr[(p)->len++] = (v); \
|
||||
} while (0)
|
||||
|
||||
#define DYNARR_POP(p) ((p)->arr[(p)->len--])
|
||||
|
||||
#define DYNARR_CLR(p) ((p)->len = 0)
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue