summaryrefslogtreecommitdiffstats
path: root/libdm/mm
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2011-03-30 12:57:03 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2011-03-30 12:57:03 +0000
commit197b5e6dc7dd8ec161ebe43c97fd2ac8384b3433 (patch)
tree11214ea5f47bb34b06743b80d1d40bd32faf11c2 /libdm/mm
parentdf336e72d2072f4c113e95deb1827e938f05ef06 (diff)
downloadlvm2-197b5e6dc7dd8ec161ebe43c97fd2ac8384b3433.tar.gz
lvm2-197b5e6dc7dd8ec161ebe43c97fd2ac8384b3433.tar.xz
lvm2-197b5e6dc7dd8ec161ebe43c97fd2ac8384b3433.zip
Word alignment for strings
Align strdup char* allocation just on 2 bytes. It looks like wasting space to align strings on 8 bytes. (Could be even 1byte - but for hashing it might eventually get better perfomance - but probably hardly measurable). TODO: check on various architectures it's not making any problems.
Diffstat (limited to 'libdm/mm')
-rw-r--r--libdm/mm/pool-debug.c2
-rw-r--r--libdm/mm/pool.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/libdm/mm/pool-debug.c b/libdm/mm/pool-debug.c
index 7cf2bac8..af1a912f 100644
--- a/libdm/mm/pool-debug.c
+++ b/libdm/mm/pool-debug.c
@@ -136,7 +136,7 @@ static struct block *_new_block(size_t s, unsigned alignment)
* I don't think LVM will use anything but default
* align.
*/
- assert(alignment == DEFAULT_ALIGNMENT);
+ assert(alignment <= DEFAULT_ALIGNMENT);
if (!b) {
log_error("Out of memory");
diff --git a/libdm/mm/pool.c b/libdm/mm/pool.c
index 825f7cad..608826b4 100644
--- a/libdm/mm/pool.c
+++ b/libdm/mm/pool.c
@@ -27,7 +27,7 @@ void dm_pools_check_leaks(void);
char *dm_pool_strdup(struct dm_pool *p, const char *str)
{
- char *ret = dm_pool_alloc(p, strlen(str) + 1);
+ char *ret = dm_pool_alloc_aligned(p, strlen(str) + 1, 2);
if (ret)
strcpy(ret, str);
@@ -37,7 +37,7 @@ char *dm_pool_strdup(struct dm_pool *p, const char *str)
char *dm_pool_strndup(struct dm_pool *p, const char *str, size_t n)
{
- char *ret = dm_pool_alloc(p, n + 1);
+ char *ret = dm_pool_alloc_aligned(p, n + 1, 2);
if (ret) {
strncpy(ret, str, n);