summaryrefslogtreecommitdiff
path: root/include/asterisk/stringfields.h
diff options
context:
space:
mode:
authorWalter Doekes <walter+asterisk@wjd.nu>2011-11-11 22:00:14 +0000
committerWalter Doekes <walter+asterisk@wjd.nu>2011-11-11 22:00:14 +0000
commit735e48f92f88d13bd877025ff51fffc9d339ddab (patch)
tree7b4eb5c3ab41cd2adc6254cd3f59a3dc3bbd9b32 /include/asterisk/stringfields.h
parent60f51c002a31e3a84b0446890f0357dfaffb85fd (diff)
Use __alignof__ instead of sizeof for stringfield length storage.
Kevin P Fleming suggested that r343157 should use __alignof__ instead of sizeof. For most systems this won't be an issue, but better fix it now while it's still fresh. Review: https://reviewboard.asterisk.org/r/1573 ........ Merged revisions 344843 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 344845 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@344846 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/stringfields.h')
-rw-r--r--include/asterisk/stringfields.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index 4039bf482..5f2ac1a73 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -135,7 +135,7 @@ struct ast_string_field_pool {
size_t size; /*!< the total size of the pool */
size_t used; /*!< the space used in the pool */
size_t active; /*!< the amount of space actively in use by fields */
- char base[0] __attribute__((aligned(sizeof(ast_string_field_allocation)))); /*!< storage space for the fields */
+ char base[0] __attribute__((aligned(__alignof__(ast_string_field_allocation)))); /*!< storage space for the fields */
};
/*!
@@ -302,8 +302,11 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head,
/*!
\brief Macro to provide access to the allocation field that lives immediately in front of a string field
\param x Pointer to the string field
+
+ Note that x must be a pointer to a byte-sized type -- normally (char *) -- or this calculation
+ would break horribly
*/
-#define AST_STRING_FIELD_ALLOCATION(x) *((ast_string_field_allocation *) (x - sizeof(ast_string_field_allocation)))
+#define AST_STRING_FIELD_ALLOCATION(x) *((ast_string_field_allocation *) (x - __alignof__(ast_string_field_allocation)))
/*!
\brief Set a field to a simple string value