1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2011-03-30 12:57:03 +00:00
parent df336e72d2
commit 197b5e6dc7
3 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.64 - 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 dm_snprintf() to fix signess warning in dm_set_dev_dir().
Use unsigned loop counter to fix signess warning in _other_node_ops(). Use unsigned loop counter to fix signess warning in _other_node_ops().
Fix const cast in dmsetup calls of dm_report_field_string(). Fix const cast in dmsetup calls of dm_report_field_string().

View 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 * I don't think LVM will use anything but default
* align. * align.
*/ */
assert(alignment == DEFAULT_ALIGNMENT); assert(alignment <= DEFAULT_ALIGNMENT);
if (!b) { if (!b) {
log_error("Out of memory"); log_error("Out of memory");

View File

@ -27,7 +27,7 @@ void dm_pools_check_leaks(void);
char *dm_pool_strdup(struct dm_pool *p, const char *str) 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) if (ret)
strcpy(ret, str); 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 *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) { if (ret) {
strncpy(ret, str, n); strncpy(ret, str, n);