moved tags to data zone to save heap for some scm

This commit is contained in:
strawmanbobi
2018-01-31 21:18:12 +08:00
parent e655ad9d20
commit 44a400b027
4 changed files with 26 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.2)
########################################################
project(irda_decoder)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DBOARD_PC)
add_definitions(-DBOARD_PC -DDEBUG)
# add_definitions(-DBOARD_PC -DBOARD_PC_JNI)
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")

View File

@@ -9,15 +9,18 @@ Revision log:
* 2017-01-03: created by strawmanbobi
**************************************************************************************/
#include <stdlib.h>
#include "../include/ir_ac_binary_parse.h"
#include "../include/ir_decode.h"
UINT16 tag_head_offset = 0;
extern struct ir_bin_buffer *p_ir_buffer;
extern struct tag_head *tags;
#if defined USE_DYNAMIC_TAG
extern struct tag_head* tags;
#else
extern struct tag_head tags[];
#endif
UINT8 tag_count = 0;
const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] =
@@ -40,11 +43,14 @@ INT8 binary_parse_offset()
tag_head_offset = (UINT16) ((tag_count << 1) + 1);
#if defined USE_DYNAMIC_TAG
tags = (t_tag_head *) ir_malloc(tag_count * sizeof(t_tag_head));
if (NULL == tags)
{
return IR_DECODE_FAILED;
}
#endif
for (i = 0; i < tag_count; i++)
{

View File

@@ -22,7 +22,12 @@ Revision log:
#include "../include/ir_utils.h"
#if defined USE_DYNAMIC_TAG
extern struct tag_head *tags;
#else
extern struct tag_head tags[];
#endif
extern UINT8 tag_count;
static INT8 ir_context_init();
@@ -87,8 +92,8 @@ INT8 ir_ac_lib_parse()
context->si.type = SWING_TYPE_NORMAL;
context->si.mode_count = 2;
}
break;
context->si.dir_index = 0;
break;
}
}
@@ -360,11 +365,13 @@ INT8 ir_ac_lib_parse()
}
}
#if defined USE_DYNAMIC_TAG
if (NULL != tags)
{
ir_free(tags);
tags = NULL;
}
#endif
ir_hex_code = (UINT8 *) ir_malloc(context->default_code.len);
if (NULL == ir_hex_code)

View File

@@ -21,8 +21,12 @@ Revision log:
struct ir_bin_buffer binary_file;
struct ir_bin_buffer *p_ir_buffer = &binary_file;
struct tag_head *tags;
#if defined USE_DYNAMIC_TAG
struct tag_head *tags;
#else
struct tag_head tags[TAG_COUNT_FOR_PROTOCOL];
#endif
UINT8 *ir_hex_code = NULL;
UINT8 ir_hex_len = 0;
@@ -375,12 +379,15 @@ static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data,
static INT8 ir_ac_lib_close()
{
#if defined USE_DYNAMIC_TAG
// free context
if (NULL != tags)
{
ir_free(tags);
tags = NULL;
}
#endif
free_ac_context();
return IR_DECODE_SUCCEEDED;