diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-04-17 19:42:34 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-04-17 19:42:34 +0200 |
commit | 07315d36030bd1cbe6acfeb3e8f60c49ba876a10 (patch) | |
tree | 9c74de4bb97507ece945576df7073a7a28f07674 /include/m_string.h | |
parent | 4656060f118caba30912cca2557d72fcea307283 (diff) | |
download | mariadb-git-07315d36030bd1cbe6acfeb3e8f60c49ba876a10.tar.gz |
strmake_buf(X,Y) helper, equivalent to strmake(X,Y,sizeof(X)-1)
with a bit of lame protection against abuse.
Diffstat (limited to 'include/m_string.h')
-rw-r--r-- | include/m_string.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/m_string.h b/include/m_string.h index 9efa0376942..990f78eb555 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -108,6 +108,15 @@ extern char *strcend(const char *, pchar); extern char *strfill(char * s,size_t len,pchar fill); extern char *strmake(char *dst,const char *src,size_t length); +#if !defined(__GNUC__) || (__GNUC__ < 4) +#define strmake_buf(D,S) strmake(D, S, sizeof(D) - 1) +#else +#define strmake_buf(D,S) ({ \ + compile_time_assert(sizeof(D) != sizeof(char*)); \ + strmake(D, S, sizeof(D) - 1); \ + }) +#endif + #ifndef strmov extern char *strmov(char *dst,const char *src); #endif |