2
0
forked from Ivasoft/DSView

replace malloc with g_malloc

This commit is contained in:
dreamsource-tai
2024-07-25 10:53:30 +08:00
parent 66ed68ea17
commit c50e8f714a
31 changed files with 116 additions and 122 deletions

View File

@@ -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__);