diff options
| author | peter <peter@pmikkelsen.com> | 2026-08-20 16:04:41 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-08-20 16:04:41 +0000 |
| commit | 3be992e3f45dcfd9f8a45fa447de3abb710819b7 (patch) | |
| tree | 6cf02c89acdb0fbf12c20f03ea190a0047221db9 /src/aplwc_internal.h | |
| parent | 3a81615601bf37ffc4f7b570030709ac0782e2ed (diff) | |
Adapt a different coding style (no typedef'ed structs, C90...), and start working on a test setup.
FossilOrigin-Name: ebb73df5fc58859b6e985c5ec84196bdd09f639dbcdc69e706f6b17652a2d413
Diffstat (limited to 'src/aplwc_internal.h')
| -rw-r--r-- | src/aplwc_internal.h | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/aplwc_internal.h b/src/aplwc_internal.h index ccf600f..97a89ba 100644 --- a/src/aplwc_internal.h +++ b/src/aplwc_internal.h @@ -5,41 +5,46 @@ #define UNUSED_PARAMETER(arg) ((void)arg) -#define RETURN_ERROR(aplwc, rc, msg) do{ \ - Aplwc *_p = (aplwc); \ - AplwcRc _r = APLWC_##rc; \ - if(_p) _p->last_error = _r; \ - return _r; \ +#define RETURN_ERROR(aplwcp, rc, msg) do{ \ + return ((aplwc)->last_error = (rc)); \ }while(0) #define NELEM(x) (sizeof(x)/sizeof(x[0])) +#if APLWC_BUILD_TYPE_DEBUG + #define ALWAYS(x) ((x) ? 1 : (assert(0), 0)) + #define NEVER(x) ((x) ? (assert(0), 1) : 0) +#elif APLWC_BUILD_TYPE_RELEASE + #define ALWAYS(x) (X) + #define NEVER(X) (X) +#elif APLWC_BUILD_TYPE_COVERAGE + #define ALWAYS(x) (1) + #define NEVER(x) (0) +#endif + +#include <assert.h> #include <stdalign.h> #include <stdbool.h> -#include <stdlib.h> -#include <stdio.h> #include <string.h> -typedef struct Memory Memory; - -struct Memory { +struct memory { uint8_t *data; size_t size; size_t offset; }; -struct Aplwc { - AplwcRc last_error; +struct aplwc { + enum aplwc_rc last_error; char last_error_msg[64]; - Memory memory; + struct memory memory; }; /* errors.c */ -const char *rc_to_string(AplwcRc); +const char *rc_to_string(enum aplwc_rc); /* memory.c */ -Memory memory_init(uint8_t *, size_t); -Aplwc *memory_alloc_aplwc(Memory *); -void memory_free_aplwc(Memory *, Aplwc *); +struct memory memory_init(uint8_t *, size_t); +struct aplwc *memory_alloc_aplwc(struct memory *); +void memory_free_aplwc(struct memory *, struct aplwc *); #endif /* APLWC_INTERNAL_H */ |