X-Git-Url: https://plomlompom.com/repos/index.html?a=blobdiff_plain;f=src%2Fkeybindings.c;h=2f27da9d04c256f3359470cead3a2623fe4e4644;hb=0f12557b88c73f8629ffafc38dc59ab5bd15e687;hp=dae549741d738c07347dccd243d1d7066db7585e;hpb=d951e2631a19500f1bb8c29f9e029a9d9fb29ae7;p=plomrogue
diff --git a/src/keybindings.c b/src/keybindings.c
index dae5497..2f27da9 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -10,20 +10,9 @@
void init_keybindings(struct World * world) {
// Initialize keybindings from file "keybindings".
FILE * file = fopen("keybindings", "r");
- uint16_t lines = 0;
- int c = 0;
- uint16_t linemax = 0;
- uint16_t c_count = 0;
- while (EOF != c) {
- c_count++;
- c = getc(file);
- if ('\n' == c) {
- if (c_count > linemax)
- linemax = c_count + 1;
- c_count = 0;
- lines++; } }
+ uint16_t lines, linemax;
+ textfile_sizes (file, &linemax, &lines);
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
- fseek(file, 0, SEEK_SET);
char * command = malloc(linemax);
uint16_t commcount = 0;
char * cmdptr;