X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Futil.h;fp=src%2Futil.h;h=f93efc8ba2f29bbea15c9915dbf0b14d7ab6e115;hp=50148af911849498a5fe79c0a2173f58f2c9143f;hb=dfc6ebacd7bcc1e6b9e7168c3e4824d241d2d5c8;hpb=0aeee13aa695ec617ec22253824f17209660bd39 diff --git a/src/util.h b/src/util.h index 50148af..f93efc8 100644 --- a/src/util.h +++ b/src/util.h @@ -1,6 +1,7 @@ #ifndef UTIL_H_ #define UTIL_H_ +#include #include "inttypes.h" #ifdef __GNUC__ @@ -240,4 +241,17 @@ unsigned int get_cs(void); void get_msr(uint32_t msr, uint32_t *low, uint32_t *high); void set_msr(uint32_t msr, uint32_t low, uint32_t high); + +/* Non-failing versions of malloc/calloc/realloc. They never return 0, they call + * demo_abort on failure. Use the macros, don't call the *_impl functions. + */ +#define malloc_nf(sz) malloc_nf_impl(sz, __FILE__, __LINE__) +void *malloc_nf_impl(size_t sz, const char *file, int line); +#define calloc_nf(n, sz) calloc_nf_impl(n, sz, __FILE__, __LINE__) +void *calloc_nf_impl(size_t num, size_t sz, const char *file, int line); +#define realloc_nf(p, sz) realloc_nf_impl(p, sz, __FILE__, __LINE__) +void *realloc_nf_impl(void *p, size_t sz, const char *file, int line); + + + #endif /* UTIL_H_ */