edje: use realloc instead of malloc and memcpy.

Summary:
Replaced malloc with realloc. Removed free. Added a Error message.

Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>

Reviewers: cedric

Reviewed By: cedric

Subscribers: devilhorns, cedric

Differential Revision: https://phab.enlightenment.org/D1766

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Srivardhan Hebbar 2014-12-12 04:22:49 +01:00 committed by Cedric BAIL
parent c501f2ce11
commit 9792943910
1 changed files with 12 additions and 5 deletions

View File

@ -1566,13 +1566,20 @@ _edje_lua_script_writer(lua_State *L EINA_UNUSED, const void *chunk_buf, size_t
Script_Lua_Writer *data;
void *old;
data = (Script_Lua_Writer *)_data;
old = data->buf;
data->buf = malloc(data->size + chunk_size);
memcpy(data->buf, old, data->size);
memcpy(&((data->buf)[data->size]), chunk_buf, chunk_size);
if (old) free(old);
data->size += chunk_size;
data->buf = realloc(data->buf, data->size + chunk_size);
if (data->buf)
{
memcpy(&((data->buf)[data->size]), chunk_buf, chunk_size);
data->size += chunk_size;
}
else
{
ERR("Failed to copy chunk buffer.\n");
data->buf = old;
}
return 0;
}