summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jrk.h32
1 files changed, 12 insertions, 20 deletions
diff --git a/jrk.h b/jrk.h
index 89148ef..3a133c8 100644
--- a/jrk.h
+++ b/jrk.h
@@ -1,22 +1,14 @@
/*
* TODO:
- * - remove assertions from here
- * nothing in here should crash the program.
- * jrk_die macros should always die, just don't call it here
- * remove JRK_NO_EXIT_ON_DIE, i dont think its elegant. it is
- * just a bandaid fix for the above issues.
- *
* - look at at the jrk_sv_chop_delim_loop stuff. there must
* must be a better way of handling things.
*
* NOTES:
- * To avoid the application from crashing when calling the die macros
- * you can define JRK_NO_EXIT_ON_DIE. This will convert all die macros
- * to log calls. It is now up to the caller to handle the errors properly.
- * Most functions that can fail will return a bool and will log themselves,
- * which should make error handling easy. Be aware that some will return a
- * negative int to indicate failure. These are normally functions that call
- * into POSIX and return sizes as to be conformant to those POSIX syscalls.
+ * - arena function failures will not crash the program but generic sb/da
+ * functions will. this isn't the most elegant but im ok with assuming
+ * mallocs will never fail and if they do you have bigger problems.
+ * however arena allocs can and will fail as they are sized by the user,
+ * so these shouldn't crash the program.
*/
#include <stdbool.h>
@@ -393,7 +385,7 @@ jrk_ecalloc(u64 nmemb, u64 size)
void *p;
if (!(p = calloc(nmemb, size)))
- jrk_ediev("jrk_ecalloc(%ld, %ld)", nmemb, size);
+ jrk_ediev("jrk_ecalloc(%ld, %ld): buy more ram lol", nmemb, size);
return p;
}
@@ -403,7 +395,7 @@ jrk_erealloc(void *ptr, u64 size)
void *p;
if (!(p = realloc(ptr, size)))
- jrk_ediev("jrk_erealloc(%p, %ld)", ptr, size);
+ jrk_ediev("jrk_erealloc(%p, %ld): buy more ram lol", ptr, size);
return p;
}
@@ -645,7 +637,7 @@ jrk_sb_fd_read_all(jrk_StringBuilder *sb, i32 fd)
u64 sz = jrk_fd_size(fd);
jrk_da_reserve(sb, sz);
if (read(fd, sb->items, sz) < 0) {
- jrk_ediev("jrk_sb_fd_read_all(%p, %d)", (void *)sb, fd);
+ jrk_errorv("jrk_sb_fd_read_all(%p, %d)", (void *)sb, fd);
return false;
}
@@ -659,7 +651,7 @@ jrk_sb_fd_write_all(jrk_StringBuilder *sb, i32 fd)
i64 result;
result = write(fd, (void *) sb->items, sb->count);
if (result < 0) {
- jrk_ediev("jrk_sb_fd_write_all(%p, %d)", (void *)sb, fd);
+ jrk_errorv("jrk_sb_fd_write_all(%p, %d)", (void *)sb, fd);
return -1;
}
@@ -699,7 +691,7 @@ jrk_fd_open_read(char *path)
i32 result = open(path, O_RDONLY);
if (result < 0) {
- jrk_ediev("jrk_fd_open_read(%s)", path);
+ jrk_errorv("jrk_fd_open_read(%s)", path);
return -1;
}
@@ -714,7 +706,7 @@ jrk_fd_open_write(char *path)
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (result < 0) {
- jrk_ediev("jrk_fd_open_write(%s)", path);
+ jrk_errorv("jrk_fd_open_write(%s)", path);
return -1;
}
@@ -729,7 +721,7 @@ jrk_fd_open_write_append(char *path)
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (result < 0) {
- jrk_ediev("jrk_fd_open_write_append(%s)", path);
+ jrk_errorv("jrk_fd_open_write_append(%s)", path);
return -1;
}