Skip to content

Comments

Fix the potential memory leak#71

Merged
jserv merged 1 commit intodevfrom
fix-memory-leak
Sep 16, 2018
Merged

Fix the potential memory leak#71
jserv merged 1 commit intodevfrom
fix-memory-leak

Conversation

@furuame
Copy link
Member

@furuame furuame commented Sep 16, 2018

The potential memory leak is induced by the improper handling exception in each PoW implementation.

@furuame furuame requested a review from ajblane September 16, 2018 01:15
@furuame
Copy link
Member Author

furuame commented Sep 16, 2018

@ajblane Could you help review and test the FPGA implementation? Thanks.

src/pow_avx.c Outdated

PoW_AVX_Context *ctx = (PoW_AVX_Context *) malloc(sizeof(PoW_AVX_Context) * impl_ctx->num_max_thread);
if (!ctx) return false;
if(!ctx) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change style back to the original.

src/pow_c.c Outdated
nonce_to_result(trytes_t, nonce, ctx->output_trytes);
nonce_to_result(tx_tryte, nonce_tryte, ctx->output_trytes);

leave:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave might be inconsistent. Change it to something like fail, bail, etc.

src/pow_c.c Outdated
static bool PoWC_Context_Initialize(ImplContext *impl_ctx)
{
int nproc = get_avail_nprocs();
if(impl_ctx->num_max_thread <= 0 || nproc <= 0) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Check the style.

src/pow_c.c Outdated

PoW_C_Context *ctx = (PoW_C_Context *) malloc(sizeof(PoW_C_Context) * impl_ctx->num_max_thread);
if (!ctx) return false;
if(!ctx) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Style.

src/pow_cl.c Outdated
freeTrobject(trytes_t);
freeTrobject(last);
/* hack */
leave:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Label naming consistency.

@jserv jserv self-requested a review September 16, 2018 04:11
@jserv jserv merged commit f879bed into dev Sep 16, 2018
@furuame furuame deleted the fix-memory-leak branch September 17, 2018 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants