Turn cheat_manager_new into static function

This commit is contained in:
twinaphex 2016-03-24 04:51:45 +01:00
parent c142b123a1
commit 6dc267ef1c
2 changed files with 32 additions and 33 deletions

View File

@ -177,6 +177,38 @@ bool cheat_manager_save(const char *path)
return ret;
}
static cheat_manager_t *cheat_manager_new(unsigned size)
{
unsigned i;
cheat_manager_t *handle = (cheat_manager_t*)
calloc(1, sizeof(struct cheat_manager));
if (!handle)
return NULL;
handle->buf_size = size;
handle->size = size;
handle->cheats = (struct item_cheat*)
calloc(handle->buf_size, sizeof(struct item_cheat));
if (!handle->cheats)
{
handle->buf_size = 0;
handle->size = 0;
handle->cheats = NULL;
return handle;
}
for (i = 0; i < handle->size; i++)
{
handle->cheats[i].desc = NULL;
handle->cheats[i].code = NULL;
handle->cheats[i].state = false;
}
return handle;
}
bool cheat_manager_load(const char *path)
{
unsigned cheats = 0, i;
@ -230,37 +262,6 @@ bool cheat_manager_load(const char *path)
return true;
}
cheat_manager_t *cheat_manager_new(unsigned size)
{
unsigned i;
cheat_manager_t *handle = (cheat_manager_t*)
calloc(1, sizeof(struct cheat_manager));
if (!handle)
return NULL;
handle->buf_size = size;
handle->size = size;
handle->cheats = (struct item_cheat*)
calloc(handle->buf_size, sizeof(struct item_cheat));
if (!handle->cheats)
{
handle->buf_size = 0;
handle->size = 0;
handle->cheats = NULL;
return handle;
}
for (i = 0; i < handle->size; i++)
{
handle->cheats[i].desc = NULL;
handle->cheats[i].code = NULL;
handle->cheats[i].state = false;
}
return handle;
}
bool cheat_manager_realloc(unsigned new_size)
{

View File

@ -27,8 +27,6 @@ typedef struct cheat_manager cheat_manager_t;
unsigned cheat_manager_get_size(void);
cheat_manager_t *cheat_manager_new(unsigned size);
bool cheat_manager_load(const char *path);
/**