X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fwincontrol.c;h=74c9c2a297d6fc9e0fcca3c1afdd83855cd56e2c;hb=c1a7e6cdb13cd7d883424afdf0fe08e9a10fbc28;hp=f4861d833c6869bc46947a5b3beb5c22651bd749;hpb=604c6b4e4faa76de673ab25aa459a35d8cf7f044;p=plomrogue diff --git a/src/wincontrol.c b/src/wincontrol.c index f4861d8..74c9c2a 100644 --- a/src/wincontrol.c +++ b/src/wincontrol.c @@ -15,8 +15,8 @@ -extern struct Win init_win_from_file(struct World * world, char * w_name, - void (* f) (struct 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/"; @@ -34,6 +34,10 @@ extern struct Win init_win_from_file(struct World * world, char * w_name, char * line = malloc(linemax); 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); /* 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); int16_t width = atoi(line); @@ -42,7 +46,10 @@ 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; - return init_win(wmeta, w_name, height, width, world, f); + struct Win * wp; // = malloc(sizeof(struct Win)); + init_win(wmeta, &wp, title, height, width, world, f); + free(title); + return wp; }