Commit 3f1b07f5 authored by Stanislav Kinsbursky's avatar Stanislav Kinsbursky Committed by Pavel Emelyanov

protobuf: move data pointer to field structure

Signed-off-by: 's avatarStanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ea5f6454
...@@ -128,6 +128,7 @@ void cr_pb_init(void) ...@@ -128,6 +128,7 @@ void cr_pb_init(void)
#define PB_PKOBJ_LOCAL_SIZE 1024 #define PB_PKOBJ_LOCAL_SIZE 1024
struct pb_pr_field_s { struct pb_pr_field_s {
void *data;
int depth; int depth;
}; };
...@@ -220,10 +221,11 @@ static void show_bool(void *msg, pb_pr_ctl_t *ctl) ...@@ -220,10 +221,11 @@ static void show_bool(void *msg, pb_pr_ctl_t *ctl)
pr_msg("False"); pr_msg("False");
} }
static void pb_show_field(const ProtobufCFieldDescriptor *fd, void *where, static void pb_show_field(const ProtobufCFieldDescriptor *fd,
unsigned long nr_fields, pb_pr_ctl_t *ctl) unsigned long nr_fields, pb_pr_ctl_t *ctl)
{ {
pb_pr_show_t show; pb_pr_show_t show;
pb_pr_field_t *field = &ctl->cur;
unsigned long counter; unsigned long counter;
size_t fsize; size_t fsize;
...@@ -253,7 +255,7 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, void *where, ...@@ -253,7 +255,7 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, void *where,
fsize = sizeof (void *); fsize = sizeof (void *);
break; break;
case PROTOBUF_C_TYPE_MESSAGE: case PROTOBUF_C_TYPE_MESSAGE:
where = (void *)(*(long *)where); field->data = (void *)(*(long *)field->data);
ctl->arg = (void *)fd->descriptor; ctl->arg = (void *)fd->descriptor;
show = show_nested_message; show = show_nested_message;
fsize = sizeof (void *); fsize = sizeof (void *);
...@@ -276,12 +278,12 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, void *where, ...@@ -276,12 +278,12 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, void *where,
break; break;
} }
show(where, ctl); show(field->data, ctl);
where += fsize; field->data += fsize;
for (counter = 0; counter < nr_fields - 1; counter++, where += fsize) { for (counter = 0; counter < nr_fields - 1; counter++, field->data += fsize) {
pr_msg(":"); pr_msg(":");
show(where, ctl); show(field->data, ctl);
} }
if (ctl->single_entry) if (ctl->single_entry)
...@@ -333,7 +335,9 @@ static void pb_show_msg(const void *msg, pb_pr_ctl_t *ctl) ...@@ -333,7 +335,9 @@ static void pb_show_msg(const void *msg, pb_pr_ctl_t *ctl)
data = (unsigned long *)*data; data = (unsigned long *)*data;
} }
pb_show_field(&fd, data, nr_fields, ctl); ctl->cur.data = data;
pb_show_field(&fd, nr_fields, ctl);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment