summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hackmann <ghackmann@google.com>2013-06-21 13:02:38 -0700
committerColin Cross <ccross@android.com>2013-06-24 16:35:46 -0700
commit836dbf65e4370df38cddc170229a7b0bdf882c8c (patch)
tree438d92641ff419d9836fbbfe992e9f6dcbcb46aa
parent1d36ee1a6e69ec529a7c43a4fe6268f85bc5134a (diff)
downloadbionic-836dbf65e4370df38cddc170229a7b0bdf882c8c.zip
bionic-836dbf65e4370df38cddc170229a7b0bdf882c8c.tar.gz
bionic-836dbf65e4370df38cddc170229a7b0bdf882c8c.tar.bz2
bionic: store property names as variable-length strings
Names are immutable, so the fixed-sized arrays can be replaced with variable-length ones to save memory (especially on internal tree nodes). Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit 492ce95d9f6149137cb5b63c55cf2b3cdbe51e5e) Change-Id: Ib074192d1b71150233d78c58e9ffcf7ecf688b6b
-rw-r--r--libc/bionic/system_properties.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libc/bionic/system_properties.c b/libc/bionic/system_properties.c
index f9671c6..481e6ae 100644
--- a/libc/bionic/system_properties.c
+++ b/libc/bionic/system_properties.c
@@ -66,9 +66,9 @@ struct prop_area {
typedef struct prop_area prop_area;
struct prop_info {
- char name[PROP_NAME_MAX];
unsigned volatile serial;
char value[PROP_VALUE_MAX];
+ char name[0];
};
typedef struct prop_info prop_info;
@@ -92,7 +92,6 @@ typedef struct prop_info prop_info;
typedef volatile uint32_t prop_off_t;
struct prop_bt {
- char name[PROP_NAME_MAX];
uint8_t namelen;
uint8_t reserved[3];
@@ -102,6 +101,8 @@ struct prop_bt {
prop_off_t right;
prop_off_t children;
+
+ char name[0];
};
typedef struct prop_bt prop_bt;
@@ -277,7 +278,7 @@ static void *new_prop_obj(size_t size, prop_off_t *off)
static prop_bt *new_prop_bt(const char *name, uint8_t namelen, prop_off_t *off)
{
prop_off_t off_tmp;
- prop_bt *bt = new_prop_obj(sizeof(prop_bt), &off_tmp);
+ prop_bt *bt = new_prop_obj(sizeof(prop_bt) + namelen + 1, &off_tmp);
if (bt) {
memcpy(bt->name, name, namelen);
bt->name[namelen] = '\0';
@@ -293,7 +294,7 @@ static prop_info *new_prop_info(const char *name, uint8_t namelen,
const char *value, uint8_t valuelen, prop_off_t *off)
{
prop_off_t off_tmp;
- prop_info *info = new_prop_obj(sizeof(prop_info), &off_tmp);
+ prop_info *info = new_prop_obj(sizeof(prop_info) + namelen + 1, &off_tmp);
if (info) {
memcpy(info->name, name, namelen);
info->name[namelen] = '\0';