Skip to content

Commit

Permalink
add deallocation, doh
Browse files Browse the repository at this point in the history
  • Loading branch information
erkmos committed May 22, 2014
1 parent f129037 commit f507c1f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cryptonight.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ void cryptonight_hash_ctx(void* output, const void* input, size_t len, struct cr
}

void cryptonight_hash(void* output, const void* input, size_t len) {
cryptonight_hash_ctx(output, input, len, malloc(sizeof(struct cryptonight_ctx)));
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
cryptonight_hash_ctx(output, input, len, ctx);
free(ctx);
}

void cryptonight_hash_ctx_aes_ni(void* output, const void* input, size_t len, struct cryptonight_ctx* ctx) {
Expand Down Expand Up @@ -269,7 +271,7 @@ int scanhash_cryptonight(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
const uint32_t Htarg = ptarget[7];
uint32_t hash[HASH_SIZE / 4] __attribute__((aligned(32)));

struct cryptonight_ctx *ctx = malloc(sizeof(struct cryptonight_ctx));
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));

if (aes_ni) {
do {
Expand All @@ -290,6 +292,8 @@ int scanhash_cryptonight(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
}
} while (likely((n <= max_nonce && !work_restart[thr_id].restart)));
}

free(ctx);
*hashes_done = n - first_nonce + 1;
return 0;
}

0 comments on commit f507c1f

Please sign in to comment.