home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Corrected window title creation.
[plomrogue]
/
src
/
wincontrol.c
diff --git
a/src/wincontrol.c
b/src/wincontrol.c
index f4861d833c6869bc46947a5b3beb5c22651bd749..793b75e2d6205b896656da6ca6cf077189b77e6d 100644
(file)
--- 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/";
{
char * err = "Trouble in init_win_from_file() with malloc().";
char * prefix = "config/windows/";
@@
-34,6
+42,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 * 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);
int16_t height = atoi(line);
exit_err(NULL == fgets(line, linemax, file), world, err);
int16_t width = atoi(line);
@@
-42,7
+54,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;
exit_err(fclose(file), world, err);
struct WinMeta * wmeta = world->wins.meta;
- return init_win(wmeta, w_name, height, width, world, f);
+ struct Win * w = malloc(sizeof(struct Win));
+ init_win(wmeta, w, title, height, width, world, f);
+ free(title);
+ return w;
}
}