changeset 465:01f5580e43d1

core: panic -> mlk_panic
author David Demelier <markand@malikania.fr>
date Mon, 27 Feb 2023 10:03:52 +0100
parents b6b1162dafa3
children 39dd7c66ebfd
files examples/example-action/example-action.c examples/example-animation/example-animation.c examples/example-audio/example-audio.c examples/example-battle/example-battle.c examples/example-cursor/example-cursor.c examples/example-debug/example-debug.c examples/example-drawable/example-drawable.c examples/example-font/example-font.c examples/example-gridmenu/example-gridmenu.c examples/example-label/example-label.c examples/example-message/example-message.c examples/example-notify/example-notify.c examples/example-sprite/example-sprite.c examples/example-trace/example-trace.c examples/example-ui/example-ui.c libmlk-core/mlk/core/alloc.c libmlk-core/mlk/core/panic.c libmlk-core/mlk/core/panic.h libmlk-example/mlk/example/registry.c libmlk-rpg/mlk/rpg/battle-indicator.c libmlk-rpg/mlk/rpg/battle-state-closing.c libmlk-rpg/mlk/rpg/message.c libmlk-ui/mlk/ui/label.c
diffstat 23 files changed, 60 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/examples/example-action/example-action.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-action/example-action.c	Mon Feb 27 10:03:52 2023 +0100
@@ -275,7 +275,7 @@
 guide_init(void)
 {
 	if (mlk_image_openmem(&guide.image, assets_sprites_people, sizeof (assets_sprites_people)) < 0)
-		panic();
+		mlk_panic();
 
 	sprite_init(&guide.sprite, &guide.image, 48, 48);
 
@@ -323,7 +323,7 @@
 chest_init(void)
 {
 	if (mlk_image_openmem(&chest.image, assets_sprites_chest, sizeof (assets_sprites_chest)) < 0)
-		panic();
+		mlk_panic();
 
 	sprite_init(&chest.sprite, &chest.image, 32, 32);
 
@@ -337,9 +337,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-action") < 0 || ui_init() < 0 || rpg_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Action", W, H) < 0)
-		panic();
+		mlk_panic();
 
 	guide_init();
 	chest_init();
--- a/examples/example-animation/example-animation.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-animation/example-animation.c	Mon Feb 27 10:03:52 2023 +0100
@@ -55,11 +55,11 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-animation") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Animation", W, H) < 0)
-		panic();
+		mlk_panic();
 	if (mlk_image_openmem(&numbers, assets_sprites_numbers, sizeof (assets_sprites_numbers)) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
--- a/examples/example-audio/example-audio.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-audio/example-audio.c	Mon Feb 27 10:03:52 2023 +0100
@@ -60,12 +60,12 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-audio") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Audio", W, H) < 0)
-		panic();
+		mlk_panic();
 	if (mlk_music_openmem(&music, assets_music_vabsounds_romance, sizeof (assets_music_vabsounds_romance)) < 0 ||
 	    sound_openmem(&sound, assets_sounds_fire, sizeof (assets_sounds_fire)) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
@@ -84,7 +84,7 @@
 	switch (ev->type) {
 	case MLK_EVENT_CLICKDOWN:
 		if (sound_play(&sound) < 0)
-			panic();
+			mlk_panic();
 		break;
 	case MLK_EVENT_KEYDOWN:
 		switch (ev->key.key) {
--- a/examples/example-battle/example-battle.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-battle/example-battle.c	Mon Feb 27 10:03:52 2023 +0100
@@ -131,9 +131,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-battle") < 0 || ui_init() < 0 || rpg_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Battle", W, H) < 0)
-		panic();
+		mlk_panic();
 
 	registry_init();
 
--- a/examples/example-cursor/example-cursor.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-cursor/example-cursor.c	Mon Feb 27 10:03:52 2023 +0100
@@ -50,9 +50,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-cursor") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Cursor", W, H) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
--- a/examples/example-debug/example-debug.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-debug/example-debug.c	Mon Feb 27 10:03:52 2023 +0100
@@ -40,9 +40,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-debug") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Debug", W, H) < 0)
-		panic();
+		mlk_panic();
 
 	debug_options.enable = 1;
 }
--- a/examples/example-drawable/example-drawable.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-drawable/example-drawable.c	Mon Feb 27 10:03:52 2023 +0100
@@ -75,13 +75,13 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-drawable") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Drawable", W, H) < 0)
-		panic();
+		mlk_panic();
 
 	/* 0: Explosion animation. */
 	if (mlk_image_openmem(&explosion_tex, assets_sprites_explosion, sizeof (assets_sprites_explosion)) < 0)
-		panic();
+		mlk_panic();
 
 	sprite_init(&explosion_sprite, &explosion_tex, 256, 256);
 }
--- a/examples/example-font/example-font.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-font/example-font.c	Mon Feb 27 10:03:52 2023 +0100
@@ -54,9 +54,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-font") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Font", W, H) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
@@ -106,7 +106,7 @@
 	mlk_painter_clear();
 
 	if (mlk_font_render(font, &tex, "Example of text. Use <Left>/<Right> to change color and <Space> to toggle antialiasing.", colors[ci]) < 0)
-		panic();
+		mlk_panic();
 
 	texture_draw(&tex, 10, 10);
 	mlk_painter_present();
--- a/examples/example-gridmenu/example-gridmenu.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-gridmenu/example-gridmenu.c	Mon Feb 27 10:03:52 2023 +0100
@@ -42,9 +42,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-gridmenu") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Grid menu", W, H) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
--- a/examples/example-label/example-label.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-label/example-label.c	Mon Feb 27 10:03:52 2023 +0100
@@ -107,9 +107,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-label") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Label", W, H) < 0)
-		panic();
+		mlk_panic();
 
 	for (size_t i = 0; i < UTIL_SIZE(table); ++i) {
 		struct label *l = &table[i].label;
--- a/examples/example-message/example-message.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-message/example-message.c	Mon Feb 27 10:03:52 2023 +0100
@@ -49,9 +49,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-message") < 0 || ui_init() < 0 || rpg_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Message", W, H) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
--- a/examples/example-notify/example-notify.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-notify/example-notify.c	Mon Feb 27 10:03:52 2023 +0100
@@ -52,11 +52,11 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-notify") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Notify", W, H) < 0)
-		panic();
+		mlk_panic();
 	if (mlk_image_openmem(&icon, assets_images_sword, sizeof (assets_images_sword)) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
--- a/examples/example-sprite/example-sprite.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-sprite/example-sprite.c	Mon Feb 27 10:03:52 2023 +0100
@@ -66,11 +66,11 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-sprite") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Sprite", W, H) < 0)
-		panic();
+		mlk_panic();
 	if (mlk_image_openmem(&texture, assets_sprites_people, sizeof (assets_sprites_people)) < 0)
-		panic();
+		mlk_panic();
 
 	sprite_init(&sprite, &texture, 48, 48);
 }
--- a/examples/example-trace/example-trace.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-trace/example-trace.c	Mon Feb 27 10:03:52 2023 +0100
@@ -41,9 +41,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-trace") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - Trace", W, H) < 0)
-		panic();
+		mlk_panic();
 
 	trace_handler = trace_hud_handler;
 }
--- a/examples/example-ui/example-ui.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/examples/example-ui/example-ui.c	Mon Feb 27 10:03:52 2023 +0100
@@ -124,9 +124,9 @@
 init(void)
 {
 	if (mlk_core_init("fr.malikania", "example-ui") < 0 || ui_init() < 0)
-		panic();
+		mlk_panic();
 	if (window_open("Example - UI", W, H) < 0)
-		panic();
+		mlk_panic();
 }
 
 static void
--- a/libmlk-core/mlk/core/alloc.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-core/mlk/core/alloc.c	Mon Feb 27 10:03:52 2023 +0100
@@ -42,7 +42,7 @@
 	void *mem;
 
 	if (!(mem = malloc(size)))
-		panicf(OOM_MSG);
+		mlk_panicf(OOM_MSG);
 
 	return mem;
 }
@@ -53,7 +53,7 @@
 	void *mem;
 
 	if (!(mem = realloc(ptr, size)) && size != 0)
-		panicf(OOM_MSG);
+		mlk_panicf(OOM_MSG);
 
 	return mem;
 }
--- a/libmlk-core/mlk/core/panic.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-core/mlk/core/panic.c	Mon Feb 27 10:03:52 2023 +0100
@@ -32,10 +32,9 @@
 }
 
 void (*panic_handler)(void) = terminate;
-void *panic_data = NULL;
 
 void
-panicf(const char *fmt, ...)
+mlk_panicf(const char *fmt, ...)
 {
 	assert(fmt);
 
@@ -49,21 +48,21 @@
 	errorva(fmt, ap);
 	va_end(ap);
 
-	panic();
+	mlk_panic();
 }
 
 void
-panicva(const char *fmt, va_list ap)
+mlk_panicva(const char *fmt, va_list ap)
 {
 	assert(fmt);
 	assert(panic_handler);
 
 	errorva(fmt, ap);
-	panic();
+	mlk_panic();
 }
 
 void
-panic(void)
+mlk_panic(void)
 {
 	assert(panic_handler);
 
--- a/libmlk-core/mlk/core/panic.h	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-core/mlk/core/panic.h	Mon Feb 27 10:03:52 2023 +0100
@@ -24,18 +24,17 @@
 #include "core.h"
 
 extern void (*panic_handler)(void);
-extern void *panic_data;
 
 MLK_CORE_BEGIN_DECLS
 
 void
-panicf(const char *, ...);
+mlk_panicf(const char *, ...);
 
 void
-panicva(const char *, va_list);
+mlk_panicva(const char *, va_list);
 
 void
-panic(void);
+mlk_panic(void);
 
 MLK_CORE_END_DECLS
 
--- a/libmlk-example/mlk/example/registry.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-example/mlk/example/registry.c	Mon Feb 27 10:03:52 2023 +0100
@@ -88,7 +88,7 @@
 		struct texture *texture = &registry_images[images[i].index];
 
 		if (mlk_image_openmem(texture, images[i].data, images[i].datasz) < 0)
-			panic();
+			mlk_panic();
 	}
 }
 
@@ -100,7 +100,7 @@
 		struct sprite *sprite = &registry_sprites[textures[i].index];
 
 		if (mlk_image_openmem(texture, textures[i].data, textures[i].datasz) < 0)
-			panic();
+			mlk_panic();
 
 		if (textures[i].cellw == 0 || textures[i].cellh == 0)
 			sprite_init(sprite, texture, texture->w, texture->h);
@@ -116,7 +116,7 @@
 		struct sound *sound = &registry_sounds[sounds[i].index];
 
 		if (sound_openmem(sound, sounds[i].data, sounds[i].datasz) < 0)
-			panic();
+			mlk_panic();
 	}
 }
 
--- a/libmlk-rpg/mlk/rpg/battle-indicator.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-indicator.c	Mon Feb 27 10:03:52 2023 +0100
@@ -64,7 +64,7 @@
 
 	if (mlk_font_render(theme->fonts[THEME_FONT_INTERFACE], &bti->tex[0], buf, bti->cur) < 0||
 	    mlk_font_render(theme->fonts[THEME_FONT_INTERFACE], &bti->tex[1], buf, 0x000000ff) < 0)
-		panic();
+		mlk_panic();
 }
 
 int
--- a/libmlk-rpg/mlk/rpg/battle-state-closing.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/battle-state-closing.c	Mon Feb 27 10:03:52 2023 +0100
@@ -66,7 +66,7 @@
 	assert(cls);
 
 	if (texture_new(&cls->texture, window.w, window.h) < 0)
-		panic();
+		mlk_panic();
 
 	MLK_PAINTER_BEGIN(&cls->texture);
 	texture_set_blend_mode(&cls->texture, TEXTURE_BLEND_BLEND);
--- a/libmlk-rpg/mlk/rpg/message.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-rpg/mlk/rpg/message.c	Mon Feb 27 10:03:52 2023 +0100
@@ -89,7 +89,7 @@
 		if (!msg->lines[i])
 			continue;
 		if (mlk_font_query(THEME(msg)->fonts[THEME_FONT_INTERFACE], msg->lines[i], &w, NULL) < 0)
-			panic();
+			mlk_panic();
 		if (w > maxw)
 			maxw = w;
 	}
@@ -119,7 +119,7 @@
 		if (!msg->lines[i])
 			continue;
 		if (mlk_font_query(theme->fonts[THEME_FONT_INTERFACE], msg->lines[i], &lw, &lh) < 0)
-			panic();
+			mlk_panic();
 
 		label.theme = theme;
 		label.x = theme->padding;
@@ -272,7 +272,7 @@
 	}
 
 	if (texture_new(&tex, msg->w, msg->h) < 0)
-		panic();
+		mlk_panic();
 
 	MLK_PAINTER_BEGIN(&tex);
 	draw_frame(msg);
--- a/libmlk-ui/mlk/ui/label.c	Mon Feb 27 09:57:15 2023 +0100
+++ b/libmlk-ui/mlk/ui/label.c	Mon Feb 27 10:03:52 2023 +0100
@@ -46,7 +46,7 @@
 	/* Shadow text, only if enabled. */
 	if (label->flags & LABEL_FLAGS_SHADOW) {
 		if (mlk_font_render(font, &tex, label->text, t->colors[THEME_COLOR_SHADOW]) < 0)
-			panic();
+			mlk_panic();
 
 		texture_draw(&tex, label->x + 1, label->y + 1);
 		texture_finish(&tex);
@@ -54,7 +54,7 @@
 
 	/* Normal text. */
 	if (mlk_font_render(font, &tex, label->text, color) < 0)
-		panic();
+		mlk_panic();
 
 	texture_draw(&tex, label->x, label->y);
 	texture_finish(&tex);
@@ -78,7 +78,7 @@
 		: t->fonts[THEME_FONT_INTERFACE];
 
 	if (mlk_font_query(f, label->text, w, h) < 0)
-		panic();
+		mlk_panic();
 }
 
 void