Idris2/support/refc/refc_util.c
Stiopa Koltsov 41c20ddf6a Assertions in RefC runtime
Better crash explicitly than debug memory violation.

The most important part of this is in `Buffer` implementation.
2021-07-17 03:59:32 +01:00

17 lines
401 B
C

#include "refc_util.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
void idris2_refc_verify_failed(const char* file, int line, const char* cond, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
char message[1000];
snprintf(message, sizeof(message), fmt, ap);
fprintf(stderr, "assertion failed in %s:%d: %s: %s\n", file, line, cond, message);
abort();
}