diff options
| author | 2024-01-02 20:58:01 -0600 | |
|---|---|---|
| committer | 2024-01-02 20:58:01 -0600 | |
| commit | e627848dcf58aa00f4eb5dc465c4a804d6576877 (patch) | |
| tree | 83d4c1c6e1ef13ed38e337b687cc7e223e3d8064 /src/macros.h | |
| parent | now loads libraries (diff) | |
library downloads complete
Diffstat (limited to 'src/macros.h')
| -rw-r--r-- | src/macros.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/macros.h b/src/macros.h index 71aa137..f15cdd7 100644 --- a/src/macros.h +++ b/src/macros.h @@ -25,6 +25,20 @@ snprintf(_var, _tmp + 1, _fmt, __VA_ARGS__); \ } while (0) +/* astrdup is a gnu extension */ +/* _var: the variable to which the duplicated string is assigned + * _sz: the length of the string duplicated (contractually) + * _in: the NUL-terminated string to duplicate */ +#define L2_ASTRDUP(_var, _sz, _in) do { \ + _sz = strlen(_in); \ + _var = alloca(_sz + 1); \ + memcpy(_var, _in, _sz); \ + (_var)[(_sz)] = '\0'; \ +} while (0) + +#define L2_BADMIN(_v1, _v2) (((_v1) < (_v2)) ? (_v1) : (_v2)) +#define L2_BADMAX(_v1, _v2) (((_v1) > (_v2)) ? (_v1) : (_v2)) + #define L2_USER_AGENT PROJECT_NAME "/0.1.0 <[email protected]>" #define L2_URL_META_BASE "https://piston-meta.mojang.com" |
