Forráskód Böngészése

Changing ckn type to pointer

Vinicius Teshima 1 éve
szülő
commit
c9649271ed
3 módosított fájl, 9 hozzáadás és 8 törlés
  1. 7 6
      src/app.h
  2. 1 1
      src/ht.h
  3. 1 1
      src/main.c

+ 7 - 6
src/app.h

@@ -49,7 +49,7 @@ struct app {
 	bool show_fps;
 	struct free_glyph_atlas *fga;
 	struct cursor_render *cr;
-	struct app_kbd_ht ckm;
+	struct app_kbd_ht *ckm;
 };
 
 #include "free_glyph.h"
@@ -116,8 +116,9 @@ app_create(const char *win_title)
 		},
 		.target_fps = 120,
 	};
-	HT_CREATE(app.ckm, 16);
-	app.ckm.hash = ht_hash_nop;
+
+	HT_CREATE(*app.ckm, 16);
+	app.ckm->hash = ht_hash_nop;
 	DA_CREATE(app.bufs);
 	DA_APPEND(app.bufs, buffer_create());
 	app.cbuf = &app.bufs.items[0];
@@ -365,7 +366,7 @@ app_add_global_keybind(struct app *app, const char *keybind,
 			.func = func,
 			.dir = dir
 		};
-		HT_ISET(app->ckm, (int64_t)(key), kbd);
+		HT_ISET(*app->ckm, (int64_t)(key), kbd);
 		return;
 	}
 	if ( kbd_str.data[0] == '<' ) {
@@ -377,7 +378,7 @@ app_add_global_keybind(struct app *app, const char *keybind,
 			.func = func,
 			.dir = dir
 		};
-		HT_ISET(app->ckm, (int64_t)(key), kbd);
+		HT_ISET(*app->ckm, (int64_t)(key), kbd);
 		return;
 	}
 
@@ -421,7 +422,7 @@ app_add_global_keybind(struct app *app, const char *keybind,
 			.func = func,
 			.dir = dir
 		};
-		HT_ISET(app->ckm, (int64_t)(key) + (int64_t)(mod), kbd);
+		HT_ISET(*app->ckm, (int64_t)(key) + (int64_t)(mod), kbd);
 	}
 
 	DA_DESTROY(words);

+ 1 - 1
src/ht.h

@@ -115,7 +115,7 @@ uint64_t ht_default_hash(const char *str, size_t str_size);
 #define _HT_SET(ht, _key, _key_size, val, _k, _it, _i)			\
 	do {								\
 		if ( (ht).size + 1 >= (ht).cap ) { \
-			HT_INC_CAP(ht);				\
+			HT_INC_CAP((ht));				\
 		}							\
 		uint64_t _k = (ht).hash((_key), (_key_size));		\
 		typeof(*(ht).items) *_it = &(ht).items[_k % (ht).cap];	\

+ 1 - 1
src/main.c

@@ -164,7 +164,7 @@ handle_events(struct app *app)
 			}
 
 			struct app_kbd kbd = {0};
-			HT_IGET(app->ckm, (int64_t)(ks.sym + mod), kbd);
+			HT_IGET(*app->ckm, (int64_t)(ks.sym + mod), kbd);
 
 			if ( kbd.func == NULL ) {
 				break;