diff options
author | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-17 09:48:30 +0100 |
---|---|---|
committer | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-17 09:48:30 +0100 |
commit | adfbe1fb82d43e0e22d56a29cccfe71ff72eb802 (patch) | |
tree | a1f6b2e88e3c2e89ae3afbbf8fa09f9b650591a3 /strings | |
parent | 734c6286e9b78927aaec9ff9f433747b92a7db57 (diff) | |
parent | ba0506676b52f2ced84c5064f5358c57ba0ba603 (diff) | |
download | mariadb-git-adfbe1fb82d43e0e22d56a29cccfe71ff72eb802.tar.gz |
Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into mysql.com:/misc/mysql/31752_/51-31752_
client/mysql.cc:
Auto merged
sql/log.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/unireg.cc:
Auto merged
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 0d26e1b61a9..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, size_t length) -{ while (length--) if (! (*dst++ = *src++)) return dst-1; |