mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
Add type and memset safe alloca wrapper.
This commit is contained in:
parent
ef4eae17c4
commit
df89ea2887
1 changed files with 5 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <alloca.h>
|
||||
|
||||
/** A list of possible position, not sex related */
|
||||
typedef enum
|
||||
|
@ -60,6 +61,10 @@ typedef struct
|
|||
#define ssizeof(foo) (ssize_t)sizeof(foo)
|
||||
#define countof(foo) (ssizeof(foo) / ssizeof(foo[0]))
|
||||
|
||||
#define p_alloca(type, count) \
|
||||
((type *)memset(alloca(sizeof(type) * (count)), \
|
||||
0, sizeof(type) * (count)))
|
||||
|
||||
#define p_alloc_nr(x) (((x) + 16) * 3 / 2)
|
||||
#define p_new(type, count) ((type *)xmalloc(sizeof(type) * (count)))
|
||||
#define p_clear(p, count) ((void)memset((p), 0, sizeof(*(p)) * (count)))
|
||||
|
|
Loading…
Reference in a new issue