[CRIU] [PATCH 00.5/10] restore: allocate pstree items from a shared pool (v2)

Andrey Vagin avagin at openvz.org
Fri Sep 13 09:04:42 EDT 2013


A pstree item will contain pid and state. Both these properties will be
determined after creating processes and will be used from the
controlling proces.

v2: fix the error path
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 pstree.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/pstree.c b/pstree.c
index ff077aa..3515571 100644
--- a/pstree.c
+++ b/pstree.c
@@ -134,9 +134,16 @@ struct pstree_item *__alloc_pstree_item(bool rst)
 {
 	struct pstree_item *item;
 
-	item = xzalloc(sizeof(*item) + (rst ? sizeof(item->rst[0]) : 0));
-	if (!item)
-		return NULL;
+	if (!rst) {
+		item = xzalloc(sizeof(*item));
+		if (!item)
+			return NULL;
+	} else {
+		item = shmalloc(sizeof(*item) + sizeof(item->rst[0]));
+		if (!item)
+			return NULL;
+		memset(item, 0, sizeof(*item) + sizeof(item->rst[0]));
+	}
 
 	INIT_LIST_HEAD(&item->children);
 	INIT_LIST_HEAD(&item->sibling);
-- 
1.8.3.1



More information about the CRIU mailing list