Skip to content

Commit

Permalink
Allocate and deallocate memory for pow_info
Browse files Browse the repository at this point in the history
  • Loading branch information
ajblane committed Sep 27, 2018
1 parent 99244d4 commit a38f269
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pow_fpga_accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,17 @@ static bool PoWFPGAAccel_Context_Initialize(ImplContext *impl_ctx)
goto fail_to_open_odata;
}

ctx->pow_info = (PoW_Info *) malloc(sizeof(PoW_Info));
if(!ctx->pow_info)
goto fail_to_malloc_pow_info;

impl_ctx->context = ctx;
pthread_mutex_init(&impl_ctx->lock, NULL);

return true;

fail_to_malloc_pow_info:
close(ctx->out_fd);
fail_to_open_odata:
close(ctx->in_fd);
fail_to_open_idata:
Expand All @@ -144,7 +150,8 @@ static void PoWFPGAAccel_Context_Destroy(ImplContext *impl_ctx)
close(ctx->in_fd);
close(ctx->out_fd);
close(ctx->ctrl_fd);


free(ctx->pow_info);
free(ctx);
}

Expand Down

0 comments on commit a38f269

Please sign in to comment.