4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
7 * This file is part of the device-mapper userspace tools.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU Lesser General Public License v.2.1.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 /* FIXME: thread unsafe */
21 static DM_LIST_INIT(_dm_pools
);
22 void dm_pools_check_leaks(void);
25 #include "pool-debug.c"
27 #include "pool-fast.c"
30 char *dm_pool_strdup(struct dm_pool
*p
, const char *str
)
32 char *ret
= dm_pool_alloc(p
, strlen(str
) + 1);
40 char *dm_pool_strndup(struct dm_pool
*p
, const char *str
, size_t n
)
42 char *ret
= dm_pool_alloc(p
, n
+ 1);
52 void *dm_pool_zalloc(struct dm_pool
*p
, size_t s
)
54 void *ptr
= dm_pool_alloc(p
, s
);
62 void dm_pools_check_leaks(void)
66 if (dm_list_empty(&_dm_pools
))
69 log_error("You have a memory leak (not released memory pool):");
70 dm_list_iterate_items(p
, &_dm_pools
) {
72 log_error(" [%p] %s (%u bytes)",
74 p
->name
, p
->stats
.bytes
);
76 log_error(" [%p]", p
);