chore(radio): Reduce size of the data structures in FLASH storage (#3979)
* Reduce size of the YamlNode structure in FLASH storage. Fix compiler warning. * Further reduction of FLASH used by YamlNode structures. * Reduce size of sensor definition arrays and audio tone volumes array.
This commit is contained in:
@@ -19,14 +19,14 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "yaml_node.h"
|
||||
#include "yaml_bits.h"
|
||||
#include "yaml_tree_walker.h"
|
||||
#include "yaml_parser.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define MIN(a,b) (a < b ? a : b)
|
||||
|
||||
static void copy_string(char* dst, uint16_t dst_len, const char* src,
|
||||
@@ -146,7 +146,7 @@ static bool yaml_output_attr(void* user, uint8_t* ptr, uint32_t bit_ofs,
|
||||
if (node->type == YDT_CUSTOM && !node->u._cust_attr.write) return true;
|
||||
|
||||
// output tag
|
||||
if (!wf(opaque, node->tag, node->tag_len)) return false;
|
||||
if (!wf(opaque, node->tag, node->tag_len())) return false;
|
||||
|
||||
if (!wf(opaque, ": ", 2)) return false;
|
||||
|
||||
@@ -268,7 +268,7 @@ bool YamlTreeWalker::findNode(const char* tag, uint8_t tag_len)
|
||||
|
||||
while(attr && attr->type != YDT_NONE) {
|
||||
|
||||
if ((tag_len == attr->tag_len)
|
||||
if ((tag_len == attr->tag_len())
|
||||
&& !strncmp(tag, attr->tag, tag_len)) {
|
||||
return true; // attribute found!
|
||||
}
|
||||
@@ -312,7 +312,7 @@ bool YamlTreeWalker::toChild()
|
||||
|
||||
bool is_array = false;
|
||||
if (attr->type == YDT_ARRAY
|
||||
&& attr->u._array.u._a.elmts > 1) {
|
||||
&& attr->elmts > 1) {
|
||||
is_array = true;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ bool YamlTreeWalker::toChild()
|
||||
if (!attr)
|
||||
return false;
|
||||
|
||||
if ((attr->type == YDT_UNION) && (attr->tag_len == 0)) {
|
||||
if ((attr->type == YDT_UNION) && (attr->tag_len() == 0)) {
|
||||
toChild();
|
||||
anon_union++;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ bool YamlTreeWalker::toNextElmt()
|
||||
setElmts(0);
|
||||
}
|
||||
|
||||
if (getElmts() < node->u._array.u._a.elmts - 1) {
|
||||
if (getElmts() < node->elmts - 1) {
|
||||
incElmts();
|
||||
rewind();
|
||||
} else {
|
||||
@@ -388,8 +388,8 @@ bool YamlTreeWalker::isElmtEmpty(uint8_t* data)
|
||||
+ getLevelOfs();
|
||||
|
||||
// assume structs aligned on 8bit boundaries
|
||||
if (node->u._array.u._a.is_active)
|
||||
return !node->u._array.u._a.is_active(this, data, bit_ofs);
|
||||
if (node->u._array.u.is_active)
|
||||
return !node->u._array.u.is_active(this, data, bit_ofs);
|
||||
|
||||
return yaml_is_zero(data, bit_ofs, node->size);
|
||||
}
|
||||
@@ -417,7 +417,7 @@ void YamlTreeWalker::toNextAttr()
|
||||
uint32_t attr_bit_ofs = getAttrOfs();
|
||||
|
||||
if (attr->type == YDT_ARRAY)
|
||||
attr_bit_ofs += ((uint32_t)attr->u._array.u._a.elmts * attr->size);
|
||||
attr_bit_ofs += ((uint32_t)attr->elmts * attr->size);
|
||||
else
|
||||
attr_bit_ofs += attr->size;
|
||||
|
||||
@@ -428,7 +428,7 @@ void YamlTreeWalker::toNextAttr()
|
||||
|
||||
// anonymous union handling
|
||||
attr = getAttr();
|
||||
if ((attr->type == YDT_UNION) && (attr->tag_len == 0)) {
|
||||
if ((attr->type == YDT_UNION) && (strlen(attr->tag) == 0)) {
|
||||
toChild();
|
||||
anon_union++;
|
||||
}
|
||||
@@ -457,7 +457,7 @@ void YamlTreeWalker::setAttrValue(char* buf, uint16_t len)
|
||||
i = yaml_str2uint(buf, len);
|
||||
|
||||
const YamlNode* node = getNode();
|
||||
if (i < node->u._array.u._a.elmts) {
|
||||
if (i < node->elmts) {
|
||||
setElmts(i);
|
||||
rewind();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user