summaryrefslogtreecommitdiff
path: root/src/console.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/console.cpp')
-rw-r--r--src/console.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/console.cpp b/src/console.cpp
index 07d218130..cf192fb33 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -13,6 +13,7 @@
#include <stdarg.h>
#include <string.h>
#include "console.h"
+#include "helpers.hpp"
#include "network/network.h"
#include "network/network_data.h"
#include "network/network_server.h"
@@ -223,7 +224,7 @@ void IConsoleInit(void)
memset(_iconsole_history, 0, sizeof(_iconsole_history));
memset(_iconsole_buffer, 0, sizeof(_iconsole_buffer));
memset(_iconsole_cbuffer, 0, sizeof(_iconsole_cbuffer));
- _iconsole_cmdline.buf = calloc(ICON_CMDLN_SIZE, sizeof(*_iconsole_cmdline.buf)); // create buffer and zero it
+ CallocT(&_iconsole_cmdline.buf, ICON_CMDLN_SIZE); // create buffer and zero it
_iconsole_cmdline.maxlength = ICON_CMDLN_SIZE;
IConsolePrintF(13, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
@@ -612,7 +613,8 @@ void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc)
{
char *new_cmd = strdup(name);
- IConsoleCmd *item_new = malloc(sizeof(IConsoleCmd));
+ IConsoleCmd *item_new;
+ MallocT(&item_new, 1);
item_new->next = NULL;
item_new->proc = proc;
@@ -649,7 +651,8 @@ void IConsoleAliasRegister(const char *name, const char *cmd)
{
char *new_alias = strdup(name);
char *cmd_aliased = strdup(cmd);
- IConsoleAlias *item_new = malloc(sizeof(IConsoleAlias));
+ IConsoleAlias *item_new;
+ MallocT(&item_new, 1);
item_new->next = NULL;
item_new->cmdline = cmd_aliased;
@@ -784,7 +787,8 @@ void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const
void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help)
{
char *new_cmd = strdup(name);
- IConsoleVar *item_new = malloc(sizeof(IConsoleVar));
+ IConsoleVar *item_new;
+ MallocT(&item_new, 1);
item_new->help = (help != NULL) ? strdup(help) : NULL;
@@ -861,7 +865,7 @@ static void IConsoleVarSetStringvalue(const IConsoleVar *var, const char *value)
if (var->type != ICONSOLE_VAR_STRING || var->addr == NULL) return;
IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_PRE_ACTION);
- ttd_strlcpy(var->addr, value, var->size);
+ ttd_strlcpy((char*)var->addr, value, var->size);
IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_POST_ACTION);
IConsoleVarPrintSetValue(var); // print out the new value, giving feedback
return;