projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e10637c
)
Plugged little linenoise memory leaks.
170/head
author
NHOrus
<jy6x2b32pie9@yahoo.com>
Fri, 30 Jun 2017 18:30:01 +0000
(21:30 +0300)
committer
NHOrus
<jy6x2b32pie9@yahoo.com>
Fri, 30 Jun 2017 18:42:37 +0000
(21:42 +0300)
main.c
patch
|
blob
|
history
misc.c
patch
|
blob
|
history
diff --git
a/main.c
b/main.c
index 95acac2fb47adcec557ecce53bf2df089704e45c..aa7a900fa8934328900f7a269ffd82d728587d7a 100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-1181,7
+1181,6
@@
Laction:
default:
BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH); // LCOV_EXCL_LINE
}
default:
BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH); // LCOV_EXCL_LINE
}
- linenoiseFree(input);
}
}
}
}
diff --git
a/misc.c
b/misc.c
index 0d2311c945318805be770491ae9890b035d535ce..59c33bdf847819e8562ca040cb9866ff61196c7f 100644
(file)
--- a/
misc.c
+++ b/
misc.c
@@
-351,9
+351,10
@@
char* get_input()
if (input == NULL) // Got EOF; return with it.
return (input);
if (input == NULL) // Got EOF; return with it.
return (input);
- else if (input[0] == '#') // Ignore comments.
+ else if (input[0] == '#') { // Ignore comments.
+ linenoiseFree(input);
continue;
continue;
- else // We have a 'normal' line; leave the loop.
+
}
else // We have a 'normal' line; leave the loop.
break;
}
break;
}
@@
-389,6
+390,8
@@
bool silent_yes()
char* firstword = (char*) xmalloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
char* firstword = (char*) xmalloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
+ linenoiseFree(reply);
+
for (int i = 0; i < (int)strlen(firstword); ++i)
firstword[i] = tolower(firstword[i]);
for (int i = 0; i < (int)strlen(firstword); ++i)
firstword[i] = tolower(firstword[i]);
@@
-408,7
+411,6
@@
bool silent_yes()
} else
rspeak(PLEASE_ANSWER);
}
} else
rspeak(PLEASE_ANSWER);
}
- linenoiseFree(reply);
return (outcome);
}
return (outcome);
}
@@
-435,6
+437,8
@@
bool yes(const char* question, const char* yes_response, const char* no_response
char* firstword = (char*) xmalloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
char* firstword = (char*) xmalloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
+ linenoiseFree(reply);
+
for (int i = 0; i < (int)strlen(firstword); ++i)
firstword[i] = tolower(firstword[i]);
for (int i = 0; i < (int)strlen(firstword); ++i)
firstword[i] = tolower(firstword[i]);
@@
-455,8
+459,9
@@
bool yes(const char* question, const char* yes_response, const char* no_response
break;
} else
rspeak(PLEASE_ANSWER);
break;
} else
rspeak(PLEASE_ANSWER);
+
}
}
- linenoiseFree(reply);
+
return (outcome);
}
return (outcome);
}