7 void *malloc_nf_impl(size_t sz, const char *file, int line)
10 if(!(p = malloc(sz))) {
11 fprintf(stderr, "%s:%d failed to allocate %lu bytes\n", file, line, (unsigned long)sz);
17 void *calloc_nf_impl(size_t num, size_t sz, const char *file, int line)
20 if(!(p = calloc(num, sz))) {
21 fprintf(stderr, "%s:%d failed to allocate %lu bytes\n", file, line, (unsigned long)(sz * num));
27 void *realloc_nf_impl(void *p, size_t sz, const char *file, int line)
29 if(!(p = realloc(p, sz))) {
30 fprintf(stderr, "%s:%d failed to realloc %lu bytes\n", file, line, (unsigned long)sz);
36 char *strdup_nf_impl(const char *s, const char *file, int line)
39 if(!(res = strdup(s))) {
40 fprintf(stderr, "%s:%d failed to duplicate string\n", file, line);
47 int match_prefix(const char *str, const char *prefix)
49 while(*str && *prefix) {
50 if(*str++ != *prefix++) {
54 return *prefix ? 0 : 1;
57 void errmsg(const char *fmt, ...)
62 tui_vmsgbox(TUI_ERROR, "error", fmt, ap);
66 void warnmsg(const char *fmt, ...)
71 tui_status(TUI_WARN, fmt, ap);
75 void infomsg(const char *fmt, ...)
80 tui_status(TUI_INFO, fmt, ap);