X-Git-Url: https://plomlompom.com/repos/test.html?a=blobdiff_plain;f=src%2Fwincontrol.c;h=793b75e2d6205b896656da6ca6cf077189b77e6d;hb=e6b7840265f17e8934500815030a2fc0553feb81;hp=cfa593b42455b81e58dd1ff325c89a128a87d1a9;hpb=f8325a4ea617b15315183d7a8027c0b913c91034;p=plomrogue
diff --git a/src/wincontrol.c b/src/wincontrol.c
index cfa593b..793b75e 100644
--- a/src/wincontrol.c
+++ b/src/wincontrol.c
@@ -15,8 +15,16 @@
-extern struct Win init_win_from_file(struct World * world, char * w_name,
- void (* f) (struct Win *))
+extern void free_win(struct Win * win)
+{
+ free(win->_title);
+ free(win);
+}
+
+
+
+extern struct Win * init_win_from_file(struct World * world, char * w_name,
+ void (* f) (struct Win *))
{
char * err = "Trouble in init_win_from_file() with malloc().";
char * prefix = "config/windows/";
@@ -35,7 +43,8 @@ extern struct Win init_win_from_file(struct World * world, char * w_name,
err = "Trouble in init_win_from_file() with fgets().";
exit_err(NULL == fgets(line, linemax, file), world, err);
char * title = malloc(strlen(line));
- memcpy(title, line, strlen(line) - 1);
+ memcpy(title, line, strlen(line) - 1); /* Eliminate newline char at end */
+ title[strlen(line) - 1] = '\0'; /* of string. */
exit_err(NULL == fgets(line, linemax, file), world, err);
int16_t height = atoi(line);
exit_err(NULL == fgets(line, linemax, file), world, err);
@@ -45,8 +54,8 @@ extern struct Win init_win_from_file(struct World * world, char * w_name,
exit_err(fclose(file), world, err);
struct WinMeta * wmeta = world->wins.meta;
- struct Win w;
- init_win(wmeta, &w, title, height, width, world, f);
+ struct Win * w = malloc(sizeof(struct Win));
+ init_win(wmeta, w, title, height, width, world, f);
free(title);
return w;
}