Commit dfdf54d9 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

pstree: allocate restore data as a tail of pstree_item (v2)

v2: Synchronize the argument type of __alloc_pstree_item and the
values you put into it. I.e. int-int or bool-bool, not bool-int.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent f7d0263c
...@@ -1080,11 +1080,11 @@ err: ...@@ -1080,11 +1080,11 @@ err:
return -1; return -1;
} }
struct pstree_item *alloc_pstree_item() struct pstree_item *__alloc_pstree_item(bool rst)
{ {
struct pstree_item *item; struct pstree_item *item;
item = xzalloc(sizeof(*item)); item = xzalloc(sizeof(*item) + (rst ? sizeof(item->rst[0]) : 0));
if (!item) if (!item)
return NULL; return NULL;
......
...@@ -95,16 +95,10 @@ static int prepare_pstree(void) ...@@ -95,16 +95,10 @@ static int prepare_pstree(void)
break; break;
ret = -1; ret = -1;
pi = alloc_pstree_item(); pi = alloc_pstree_item_with_rst();
if (pi == NULL) if (pi == NULL)
break; break;
pi->rst = xzalloc(sizeof(*pi->rst));
if (pi->rst == NULL) {
xfree(pi);
break;
}
pi->pid = e.pid; pi->pid = e.pid;
pi->pgid = e.pgid; pi->pgid = e.pgid;
pi->sid = e.sid; pi->sid = e.sid;
......
...@@ -185,10 +185,12 @@ struct pstree_item { ...@@ -185,10 +185,12 @@ struct pstree_item {
int state; /* TASK_XXX constants */ int state; /* TASK_XXX constants */
int nr_threads; /* number of threads */ int nr_threads; /* number of threads */
u32 *threads; /* array of threads */ u32 *threads; /* array of threads */
struct rst_info *rst; struct rst_info rst[0];
}; };
extern struct pstree_item *alloc_pstree_item(void); extern struct pstree_item *__alloc_pstree_item(bool rst);
#define alloc_pstree_item() __alloc_pstree_item(false)
#define alloc_pstree_item_with_rst() __alloc_pstree_item(true)
extern struct pstree_item *pstree_item_next(struct pstree_item *item); extern struct pstree_item *pstree_item_next(struct pstree_item *item);
#define for_each_pstree_item(pi) \ #define for_each_pstree_item(pi) \
......
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