]> sourceware.org Git - lvm2.git/commitdiff
Word alignment for strings
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 30 Mar 2011 12:57:03 +0000 (12:57 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 30 Mar 2011 12:57:03 +0000 (12:57 +0000)
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.

WHATS_NEW_DM
libdm/mm/pool-debug.c
libdm/mm/pool.c

index 59f544d61dd53ef0357ba20d52b1e1b576dd3eb0..eb14d38fcce31987faf5e2f7f1d92df057092159 100644 (file)
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Use word alignment for dm_pool_strdup() and dm_pool_strndup().
   Use dm_snprintf() to fix signess warning in dm_set_dev_dir().
   Use unsigned loop counter to fix signess warning in _other_node_ops().
   Fix const cast in dmsetup calls of dm_report_field_string().
index 7cf2bac8997538be50dcc0435733a0141a023715..af1a912fcb0c19a8fef230fffe9b45a22813255f 100644 (file)
@@ -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");
index 825f7cad8ce11f392b9f69445d5b8458e3bd8eee..608826b4781d465fff860a8fe4186c4f98f19f61 100644 (file)
@@ -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);
This page took 0.044607 seconds and 5 git commands to generate.