X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fmisc.c;h=2cf9e62f936671b84faeca3eaecb4df8cb5fd267;hb=00a7727e37e2d80ff115f03e7971a92c66edcd96;hp=e71770daf8361b8a6df34c8b35f27b137596414f;hpb=c72ed6261224cc0a1b8aa72f6af966715970ff60;p=plomrogue diff --git a/src/misc.c b/src/misc.c index e71770d..2cf9e62 100644 --- a/src/misc.c +++ b/src/misc.c @@ -16,7 +16,7 @@ #include "map.h" /* for Map struct, is_passable() */ #include "main.h" /* for world global */ #include "yx_uint16.h" /* for yx_uint16 struct */ -#include "rexit.h" /* for exit_err() */ +#include "rexit.h" /* for exit_err(), exit_trouble() */ #include "wincontrol.h" /* for init_winconfs(), init_wins(), free_winconfs(), * sorted_wintoggle_and_activate() */ @@ -34,27 +34,10 @@ extern uint16_t rrand() -extern char * trouble_msg(char * parent, char * child) -{ - char * p1 = "Trouble in "; - char * p2 = " with "; - char * p3 = "."; - uint16_t size = strlen(p1) + strlen(parent) + strlen(p2) + strlen(child) - + strlen(p3) + 1; - char * msg = malloc(size); - exit_err(NULL == msg, "malloc() in trouble_msg() failed."); - sprintf(msg, "%s%s%s%s%s", p1, parent, p2, child, p3); - return msg; -} - - - extern void * try_malloc(size_t size, char * f) { - char * msg = trouble_msg(f, "malloc()"); void * p = malloc(size); - exit_err(NULL == p, msg); - free(msg); + exit_trouble(NULL == p, f, "malloc()"); return p; } @@ -62,10 +45,8 @@ extern void * try_malloc(size_t size, char * f) extern void * try_calloc(size_t size1, size_t size2, char * f) { - char * msg = trouble_msg(f, "calloc()"); void * p = calloc(size1, size2); - exit_err(NULL == p, msg); - free(msg); + exit_trouble(NULL == p, f, "calloc()"); return p; }