projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove unused enum.
[open-adventure.git]
/
misc.c
diff --git
a/misc.c
b/misc.c
index d33bc510c9b7fa05d500c569df9cc7f7a4e5585e..d5b7f6554a1b95f3ad74645a918a0579d4ac1c6d 100644
(file)
--- a/
misc.c
+++ b/
misc.c
@@
-10,9
+10,9
@@
#include "advent.h"
#include "dungeon.h"
#include "advent.h"
#include "dungeon.h"
-static void* x
m
alloc(size_t size)
+static void* x
c
alloc(size_t size)
{
{
- void* ptr =
malloc(size
);
+ void* ptr =
calloc(size, 1
);
if (ptr == NULL) {
// LCOV_EXCL_START
// exclude from coverage analysis because we can't simulate an out of memory error in testing
if (ptr == NULL) {
// LCOV_EXCL_START
// exclude from coverage analysis because we can't simulate an out of memory error in testing
@@
-74,7
+74,7
@@
static void vspeak(const char* msg, bool blank, va_list ap)
// Rendered string
ssize_t size = 2000; /* msglen > 50 ? msglen*2 : 100; */
// Rendered string
ssize_t size = 2000; /* msglen > 50 ? msglen*2 : 100; */
- char* rendered = x
m
alloc(size);
+ char* rendered = x
c
alloc(size);
char* renderp = rendered;
// Handle format specifiers (including the custom %S) by
char* renderp = rendered;
// Handle format specifiers (including the custom %S) by
@@
-113,7
+113,7
@@
static void vspeak(const char* msg, bool blank, va_list ap)
// Unmodified string specifier.
if (msg[i] == 's') {
char *arg = va_arg(ap, char *);
// Unmodified string specifier.
if (msg[i] == 's') {
char *arg = va_arg(ap, char *);
- strncat(renderp, arg, size);
+ strncat(renderp, arg, size
- 1
);
size_t len = strlen(renderp);
renderp += len;
size -= len;
size_t len = strlen(renderp);
renderp += len;
size -= len;
@@
-204,7
+204,7
@@
void rspeak(vocab_t i, ...)
void echo_input(FILE* destination, const char* input_prompt, const char* input)
{
size_t len = strlen(input_prompt) + strlen(input) + 1;
void echo_input(FILE* destination, const char* input_prompt, const char* input)
{
size_t len = strlen(input_prompt) + strlen(input) + 1;
- char* prompt_and_input = (char*) x
m
alloc(len);
+ char* prompt_and_input = (char*) x
c
alloc(len);
strcpy(prompt_and_input, input_prompt);
strcat(prompt_and_input, input);
fprintf(destination, "%s\n", prompt_and_input);
strcpy(prompt_and_input, input_prompt);
strcat(prompt_and_input, input);
fprintf(destination, "%s\n", prompt_and_input);
@@
-289,7
+289,7
@@
bool silent_yes()
continue;
}
continue;
}
- char* firstword = (char*) x
m
alloc(strlen(reply) + 1);
+ char* firstword = (char*) x
c
alloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
free(reply);
sscanf(reply, "%s", firstword);
free(reply);
@@
-343,7
+343,7
@@
bool yes(const char* question, const char* yes_response, const char* no_response
continue;
}
continue;
}
- char* firstword = (char*) x
m
alloc(strlen(reply) + 1);
+ char* firstword = (char*) x
c
alloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
free(reply);
sscanf(reply, "%s", firstword);
free(reply);
@@
-378,7
+378,7
@@
bool yes(const char* question, const char* yes_response, const char* no_response
/* Data structure routines */
/* Data structure routines */
-int get_motion_vocab_id(const char* word)
+
static
int get_motion_vocab_id(const char* word)
// Return the first motion number that has 'word' as one of its words.
{
for (int i = 0; i < NMOTIONS; ++i) {
// Return the first motion number that has 'word' as one of its words.
{
for (int i = 0; i < NMOTIONS; ++i) {
@@
-393,7
+393,7
@@
int get_motion_vocab_id(const char* word)
return (WORD_NOT_FOUND);
}
return (WORD_NOT_FOUND);
}
-int get_object_vocab_id(const char* word)
+
static
int get_object_vocab_id(const char* word)
// Return the first object number that has 'word' as one of its words.
{
for (int i = 0; i < NOBJECTS + 1; ++i) { // FIXME: the + 1 should go when 1-indexing for objects is removed
// Return the first object number that has 'word' as one of its words.
{
for (int i = 0; i < NOBJECTS + 1; ++i) { // FIXME: the + 1 should go when 1-indexing for objects is removed
@@
-406,7
+406,7
@@
int get_object_vocab_id(const char* word)
return (WORD_NOT_FOUND);
}
return (WORD_NOT_FOUND);
}
-int get_action_vocab_id(const char* word)
+
static
int get_action_vocab_id(const char* word)
// Return the first motion number that has 'word' as one of its words.
{
for (int i = 0; i < NACTIONS; ++i) {
// Return the first motion number that has 'word' as one of its words.
{
for (int i = 0; i < NACTIONS; ++i) {
@@
-421,7
+421,7
@@
int get_action_vocab_id(const char* word)
return (WORD_NOT_FOUND);
}
return (WORD_NOT_FOUND);
}
-int get_special_vocab_id(const char* word)
+
static
int get_special_vocab_id(const char* word)
// Return the first special number that has 'word' as one of its words.
{
for (int i = 0; i < NSPECIALS; ++i) {
// Return the first special number that has 'word' as one of its words.
{
for (int i = 0; i < NSPECIALS; ++i) {