summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2015-10-20 14:09:09 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2015-10-23 16:03:27 +0200
commit5d68fe6965c5098c014512d20995eddbff635b62 (patch)
treecd96da376bbb052cce6fb42640ee3e722f81cca7
parent3a42c13ccf151c3afdeab362c8541b5d249fb01e (diff)
downloadlvm2-5d68fe6965c5098c014512d20995eddbff635b62.tar.gz
str_list: also allow memory allocation without memory pool
-rw-r--r--lib/datastruct/str_list.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c
index 1d3f08ad1..25ffddd2c 100644
--- a/lib/datastruct/str_list.c
+++ b/lib/datastruct/str_list.c
@@ -20,7 +20,8 @@ struct dm_list *str_list_create(struct dm_pool *mem)
{
struct dm_list *sl;
- if (!(sl = dm_pool_alloc(mem, sizeof(struct dm_list)))) {
+ if (!(sl = mem ? dm_pool_alloc(mem, sizeof(struct dm_list))
+ : dm_malloc(sizeof(struct dm_list)))) {
log_errno(ENOMEM, "str_list allocation failed");
return NULL;
}
@@ -37,7 +38,8 @@ static int _str_list_add_no_dup_check(struct dm_pool *mem, struct dm_list *sll,
if (!str)
return_0;
- if (!(sln = dm_pool_alloc(mem, sizeof(*sln))))
+ if (!(sln = mem ? dm_pool_alloc(mem, sizeof(*sln))
+ : dm_malloc(sizeof(*sln))))
return_0;
sln->str = str;