forked from Ivasoft/DSView
replace malloc with g_malloc
This commit is contained in:
@@ -60,7 +60,7 @@ static int init(struct sr_output *o, GHashTable *options)
|
||||
if (!o || !o->sdi)
|
||||
return SR_ERR_ARG;
|
||||
|
||||
ctx = malloc(sizeof(struct context));
|
||||
ctx = g_try_malloc0(sizeof(struct context));
|
||||
if (ctx == NULL){
|
||||
sr_err("%s,ERROR:failed to alloc memory.", __func__);
|
||||
return SR_ERR;
|
||||
@@ -83,7 +83,7 @@ static int init(struct sr_output *o, GHashTable *options)
|
||||
sr_err("No logic channel enabled.");
|
||||
return SR_ERR;
|
||||
}
|
||||
ctx->channel_index = malloc(sizeof(int) * ctx->num_enabled_channels);
|
||||
ctx->channel_index = g_try_malloc0(sizeof(int) * ctx->num_enabled_channels);
|
||||
|
||||
if (ctx->channel_index == NULL){
|
||||
sr_err("%s,ERROR:failed to alloc memory.", __func__);
|
||||
@@ -183,7 +183,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
|
||||
|
||||
if (!ctx->prevsample) {
|
||||
/* Can't allocate this until we know the stream's unitsize. */
|
||||
ctx->prevsample = malloc(logic->unitsize);
|
||||
ctx->prevsample = g_try_malloc0(logic->unitsize);
|
||||
|
||||
if (ctx->prevsample == NULL){
|
||||
sr_err("%s,ERROR:failed to alloc memory.", __func__);
|
||||
|
||||
Reference in New Issue
Block a user