mirror of
https://github.com/CPunch/Laika.git
synced 2024-12-26 12:50:06 +00:00
minor refactoring, proper no op macros
This commit is contained in:
parent
5ece351025
commit
42199fc7c9
@ -15,7 +15,7 @@
|
||||
#ifdef DEBUG
|
||||
#define LAIKA_DEBUG(...) printf("[~] " __VA_ARGS__); fflush(stdout);
|
||||
#else
|
||||
#define LAIKA_DEBUG(...)
|
||||
#define LAIKA_DEBUG(...) ((void)0) /* no op */
|
||||
#endif
|
||||
|
||||
#endif
|
@ -29,7 +29,7 @@
|
||||
else \
|
||||
exit(1); \
|
||||
} while(0);
|
||||
#define LAIKA_WARN(...)
|
||||
#define LAIKA_WARN(...) ((void)0) /* no op */
|
||||
#else
|
||||
#define LAIKA_ERROR(...) do { \
|
||||
printf("[ERROR] : " __VA_ARGS__); \
|
||||
|
@ -11,8 +11,7 @@
|
||||
#define ENDVLA(var) laikaM_free(var);
|
||||
#else
|
||||
#define VLA(type, var, sz) type var[sz];
|
||||
/* stubbed */
|
||||
#define ENDVLA(var)
|
||||
#define ENDVLA(var) ((void)0) /* no op */
|
||||
#endif
|
||||
|
||||
#define laikaM_malloc(sz) laikaM_realloc(NULL, sz)
|
||||
@ -25,20 +24,20 @@
|
||||
}
|
||||
|
||||
/* moves array elements above indx down by numElem, removing numElem elements at indx */
|
||||
#define laikaM_rmvarray(buf, count, indx, numElem) { \
|
||||
#define laikaM_rmvarray(buf, count, indx, numElem) do { \
|
||||
int _i, _sz = ((count-indx)-numElem); \
|
||||
for (_i = 0; _i < _sz; _i++) \
|
||||
buf[indx+_i] = buf[indx+numElem+_i]; \
|
||||
count -= numElem; \
|
||||
}
|
||||
} while(0);
|
||||
|
||||
/* moves array elements above indx up by numElem, inserting numElem elements at indx */
|
||||
#define laikaM_insertarray(buf, count, indx, numElem) { \
|
||||
#define laikaM_insertarray(buf, count, indx, numElem) do { \
|
||||
int _i; \
|
||||
for (_i = count; _i > indx; _i--) \
|
||||
buf[_i] = buf[_i-1]; \
|
||||
count += numElem; \
|
||||
}
|
||||
} while(0);
|
||||
|
||||
void *laikaM_realloc(void *buf, size_t sz);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user