From 4b20d830c47b6ea2a731ac8b7c82e8ac118f8cc9 Mon Sep 17 00:00:00 2001 From: Marrub Date: Mon, 21 Nov 2016 01:02:56 -0500 Subject: [PATCH] Types: Add Lth_VectorAlloc and move Lth_pfor --- lithos_c/inc/Lth_stdlib.h | 2 -- lithos_c/inc/Lth_types.h | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lithos_c/inc/Lth_stdlib.h b/lithos_c/inc/Lth_stdlib.h index c70f8e1..8681b35 100644 --- a/lithos_c/inc/Lth_stdlib.h +++ b/lithos_c/inc/Lth_stdlib.h @@ -16,8 +16,6 @@ #define Lth_isidenti(c) \ (isalnum(c) || c == '_' || c == '$' || c == '\'' || c > 0x80) -// Post-for. Sort of. -#define Lth_pfor(cond, expr) while((cond) && ((expr), true)) // Extern Functions ----------------------------------------------------------| diff --git a/lithos_c/inc/Lth_types.h b/lithos_c/inc/Lth_types.h index 4d192df..2849cde 100644 --- a/lithos_c/inc/Lth_types.h +++ b/lithos_c/inc/Lth_types.h @@ -22,12 +22,16 @@ #define Lth_Vector(type) struct { type *data; size_t size, bufsz; } #define Lth_VectorForEach(type, vec) \ for(type itr = (vec).data; itr != (vec).data + (vec).size; itr++) +#define Lth_VectorAlloc(type, vec) \ + (vec).data = calloc((vec).size, sizeof(type)) #define Lth_Pair(typef, types) struct { typef first; types second; } #define Lth_WithMbState() \ __with(mbstate_t state; memset(&state, 0, sizeof(state));) +#define Lth_pfor(cond, expr) while((cond) && ((expr), true)) + // Type Definitions ----------------------------------------------------------|