(task_save.c) Use malloc
This commit is contained in:
parent
862cf48108
commit
57ded65189
|
@ -119,17 +119,15 @@ struct autosave_st
|
||||||
struct autosave
|
struct autosave
|
||||||
{
|
{
|
||||||
volatile bool quit;
|
volatile bool quit;
|
||||||
slock_t *lock;
|
size_t bufsize;
|
||||||
|
unsigned interval;
|
||||||
slock_t *cond_lock;
|
|
||||||
scond_t *cond;
|
|
||||||
sthread_t *thread;
|
|
||||||
|
|
||||||
void *buffer;
|
void *buffer;
|
||||||
const void *retro_buffer;
|
const void *retro_buffer;
|
||||||
const char *path;
|
const char *path;
|
||||||
size_t bufsize;
|
slock_t *lock;
|
||||||
unsigned interval;
|
slock_t *cond_lock;
|
||||||
|
scond_t *cond;
|
||||||
|
sthread_t *thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct autosave_st autosave_state;
|
static struct autosave_st autosave_state;
|
||||||
|
@ -213,15 +211,16 @@ static autosave_t *autosave_new(const char *path,
|
||||||
const void *data, size_t size,
|
const void *data, size_t size,
|
||||||
unsigned interval)
|
unsigned interval)
|
||||||
{
|
{
|
||||||
autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
|
autosave_t *handle = (autosave_t*)malloc(sizeof(*handle));
|
||||||
if (!handle)
|
if (!handle)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
handle->quit = false;
|
||||||
handle->bufsize = size;
|
handle->bufsize = size;
|
||||||
handle->interval = interval;
|
handle->interval = interval;
|
||||||
handle->path = path;
|
|
||||||
handle->buffer = malloc(size);
|
handle->buffer = malloc(size);
|
||||||
handle->retro_buffer = data;
|
handle->retro_buffer = data;
|
||||||
|
handle->path = path;
|
||||||
|
|
||||||
if (!handle->buffer)
|
if (!handle->buffer)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -231,7 +230,6 @@ static autosave_t *autosave_new(const char *path,
|
||||||
handle->lock = slock_new();
|
handle->lock = slock_new();
|
||||||
handle->cond_lock = slock_new();
|
handle->cond_lock = slock_new();
|
||||||
handle->cond = scond_new();
|
handle->cond = scond_new();
|
||||||
|
|
||||||
handle->thread = sthread_create(autosave_thread, handle);
|
handle->thread = sthread_create(autosave_thread, handle);
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
|
@ -276,8 +274,10 @@ bool autosave_init(void)
|
||||||
if (autosave_interval < 1 || !task_save_files)
|
if (autosave_interval < 1 || !task_save_files)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
list = (autosave_t**)calloc(task_save_files->size,
|
list = (autosave_t**)
|
||||||
sizeof(*autosave_state.list));
|
calloc(task_save_files->size,
|
||||||
|
sizeof(*autosave_state.list));
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue