Exit on Node.js assertion failures

This commit is contained in:
Wilson Lin 2021-01-06 17:13:07 +11:00
parent b1968e539d
commit de41c79092
1 changed files with 4 additions and 2 deletions

View File

@ -12,14 +12,16 @@ typedef struct Cfg Cfg;
static inline void* assert_malloc(size_t bytes) {
void* ptr = malloc(bytes);
if (ptr == NULL) {
// TODO
fprintf(stderr, "[Node.js minify-html] Internal assertion error: failed to allocate memory\n");
exit(67);
}
return ptr;
}
static inline void assert_ok(napi_status status) {
if (status != napi_ok) {
// TODO
fprintf(stderr, "[Node.js minify-html] Internal assertion error: N-API status not OK\n");
exit(67);
}
}