diff options
author | tnurnberg@white.intern.koehntopp.de <> | 2007-11-26 09:00:41 +0100 |
---|---|---|
committer | tnurnberg@white.intern.koehntopp.de <> | 2007-11-26 09:00:41 +0100 |
commit | f91cf9c7cf13c82db0447a30dd9cc91be1b12cad (patch) | |
tree | 198fef3c0399dd79a990104be1deec976b3ae8ea /strings | |
parent | 127f8e968ea6c11ab8daee9c8b64109914576a57 (diff) | |
parent | 1a95ed1df2bdd26444a973e07ffd84c045deb734 (diff) | |
download | mariadb-git-f91cf9c7cf13c82db0447a30dd9cc91be1b12cad.tar.gz |
Merge mysql.com:/misc/mysql/31752_/41-31752_
into mysql.com:/misc/mysql/31752_/50-31752_
Diffstat (limited to 'strings')
-rw-r--r-- | strings/strmake.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/strings/strmake.c b/strings/strmake.c index 5ca4688de46..05b5878d99c 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -27,23 +27,25 @@ #include <my_global.h> #include "m_string.h" -#ifdef BAD_STRING_COMPILER - -char *strmake(char *dst,const char *src,uint length) +char *strmake(register char *dst, register const char *src, uint length) { - reg1 char *res; - - if ((res=memccpy(dst,src,0,length))) - return res-1; - dst[length]=0; - return dst+length; -} - -#define strmake strmake_overlapp /* Use orginal for overlapping str */ +#ifdef EXTRA_DEBUG + /* + 'length' is the maximum length of the string; the buffer needs + to be one character larger to accomodate the terminating '\0'. + This is easy to get wrong, so we make sure we write to the + entire length of the buffer to identify incorrect buffer-sizes. + We only initialise the "unused" part of the buffer here, a) for + efficiency, and b) because dst==src is allowed, so initialising + the entire buffer would overwrite the source-string. Also, we + write a character rather than '\0' as this makes spotting these + problems in the results easier. + */ + uint n= strlen(src) + 1; + if (n <= length) + memset(dst + n, (int) 'Z', length - n + 1); #endif -char *strmake(register char *dst, register const char *src, uint length) -{ while (length--) if (! (*dst++ = *src++)) return dst-1; |