From c2ca44be9f6408351cfe32e855b1472ec155b9b2 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 14:34:29 -0500 Subject: free decoder context --- tools/ootx_decode/ootx_decode.c | 5 ++++- tools/ootx_decode/ootx_decoder.c | 6 ++++++ tools/ootx_decode/ootx_decoder.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 9e76d8f..1e93574 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -197,7 +197,7 @@ void acode_test() { // if (current_lighthouse==0) { ootx_accumulate_bit(c_ctx, (acode & 0x02) >> 1); // } - } + } } int main(int argc, char* argv[]) @@ -209,5 +209,8 @@ int main(int argc, char* argv[]) // acode_test(); // hello_world_test(); + ootx_free_decoder_context(ctx); + ootx_free_decoder_context(ctx+1); + return 0; } \ No newline at end of file diff --git a/tools/ootx_decode/ootx_decoder.c b/tools/ootx_decode/ootx_decoder.c index dc5d50a..f308bfb 100644 --- a/tools/ootx_decode/ootx_decoder.c +++ b/tools/ootx_decode/ootx_decoder.c @@ -33,6 +33,12 @@ void ootx_init_decoder_context(ootx_decoder_context *ctx) { *(ctx->payload_size) = 0; } +void ootx_free_decoder_context(ootx_decoder_context *ctx) { + free(ctx->buffer); + ctx->buffer = NULL; + ctx->payload_size = NULL; +} + /* how to decode pulses ticks>2000 && delta>100000== master lighthouse diff --git a/tools/ootx_decode/ootx_decoder.h b/tools/ootx_decode/ootx_decoder.h index 38c273b..4ec1fd1 100644 --- a/tools/ootx_decode/ootx_decoder.h +++ b/tools/ootx_decode/ootx_decoder.h @@ -59,6 +59,7 @@ void print_lighthouse_info_v6(lighthouse_info_v6* lhi); void ootx_process_bit(ootx_decoder_context *ctx, uint32_t length); void ootx_init_decoder_context(ootx_decoder_context *ctx); int8_t ootx_decode_lighthouse_number(uint8_t last_num, uint32_t ticks, int32_t delta); +void ootx_free_decoder_context(ootx_decoder_context *ctx); void ootx_accumulate_bit(ootx_decoder_context *ctx, uint8_t bit); uint8_t ootx_pump_greatest_bit(ootx_decoder_context *ctx); -- cgit v1.2.3