[CRIU] [PATCH v2 05/13] protobuf: move data pointer to field
structure
Kinsbursky Stanislav
skinsbursky at openvz.org
Mon Aug 6 12:11:21 EDT 2012
From: Stanislav Kinsbursky <skinsbursky at openvz.org>
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
protobuf.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
-------------- next part --------------
diff --git a/protobuf.c b/protobuf.c
index d4d2e3d..3fd32d3 100644
--- a/protobuf.c
+++ b/protobuf.c
@@ -21,6 +21,7 @@
#define PB_PKOBJ_LOCAL_SIZE 1024
struct pb_pr_field_s {
+ void *data;
int depth;
};
@@ -103,10 +104,11 @@ static void show_enum(void *msg, pb_pr_ctl_t *ctl)
pr_msg("%d", val);
}
-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)
{
pb_pr_show_t show;
+ pb_pr_field_t *field = &ctl->cur;
unsigned long counter;
size_t fsize;
@@ -136,7 +138,7 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, void *where,
fsize = sizeof (void *);
break;
case PROTOBUF_C_TYPE_MESSAGE:
- where = (void *)(*(long *)where);
+ field->data = (void *)(*(long *)field->data);
ctl->arg = (void *)fd->descriptor;
show = show_nested_message;
fsize = sizeof (void *);
@@ -156,12 +158,12 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, void *where,
break;
}
- show(where, ctl);
- where += fsize;
+ show(field->data, ctl);
+ 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(":");
- show(where, ctl);
+ show(field->data, ctl);
}
if (ctl->single_entry)
@@ -213,7 +215,9 @@ static void pb_show_msg(const void *msg, pb_pr_ctl_t *ctl)
data = (unsigned long *)*data;
}
- pb_show_field(&fd, data, nr_fields, ctl);
+ ctl->cur.data = data;
+
+ pb_show_field(&fd, nr_fields, ctl);
}
}
More information about the CRIU
mailing list