mirror of
https://github.com/CPunch/Laika.git
synced 2024-11-22 04: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
|
#ifdef DEBUG
|
||||||
#define LAIKA_DEBUG(...) printf("[~] " __VA_ARGS__); fflush(stdout);
|
#define LAIKA_DEBUG(...) printf("[~] " __VA_ARGS__); fflush(stdout);
|
||||||
#else
|
#else
|
||||||
#define LAIKA_DEBUG(...)
|
#define LAIKA_DEBUG(...) ((void)0) /* no op */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -29,7 +29,7 @@
|
|||||||
else \
|
else \
|
||||||
exit(1); \
|
exit(1); \
|
||||||
} while(0);
|
} while(0);
|
||||||
#define LAIKA_WARN(...)
|
#define LAIKA_WARN(...) ((void)0) /* no op */
|
||||||
#else
|
#else
|
||||||
#define LAIKA_ERROR(...) do { \
|
#define LAIKA_ERROR(...) do { \
|
||||||
printf("[ERROR] : " __VA_ARGS__); \
|
printf("[ERROR] : " __VA_ARGS__); \
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
#define ENDVLA(var) laikaM_free(var);
|
#define ENDVLA(var) laikaM_free(var);
|
||||||
#else
|
#else
|
||||||
#define VLA(type, var, sz) type var[sz];
|
#define VLA(type, var, sz) type var[sz];
|
||||||
/* stubbed */
|
#define ENDVLA(var) ((void)0) /* no op */
|
||||||
#define ENDVLA(var)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define laikaM_malloc(sz) laikaM_realloc(NULL, sz)
|
#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 */
|
/* 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); \
|
int _i, _sz = ((count-indx)-numElem); \
|
||||||
for (_i = 0; _i < _sz; _i++) \
|
for (_i = 0; _i < _sz; _i++) \
|
||||||
buf[indx+_i] = buf[indx+numElem+_i]; \
|
buf[indx+_i] = buf[indx+numElem+_i]; \
|
||||||
count -= numElem; \
|
count -= numElem; \
|
||||||
}
|
} while(0);
|
||||||
|
|
||||||
/* moves array elements above indx up by numElem, inserting numElem elements at indx */
|
/* 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; \
|
int _i; \
|
||||||
for (_i = count; _i > indx; _i--) \
|
for (_i = count; _i > indx; _i--) \
|
||||||
buf[_i] = buf[_i-1]; \
|
buf[_i] = buf[_i-1]; \
|
||||||
count += numElem; \
|
count += numElem; \
|
||||||
}
|
} while(0);
|
||||||
|
|
||||||
void *laikaM_realloc(void *buf, size_t sz);
|
void *laikaM_realloc(void *buf, size_t sz);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user