diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2007-03-15 10:14:23 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2007-03-15 10:14:23 (GMT) |
commit | cc52853c15833c9a18be11c140b99d94d9e06e9e (patch) | |
tree | 5300b179faf00eea740dda6ee3be5343c70b1c79 /qtools | |
parent | eb591296685b8268427173e0a24f74abd987170d (diff) | |
download | Doxygen-cc52853c15833c9a18be11c140b99d94d9e06e9e.zip Doxygen-cc52853c15833c9a18be11c140b99d94d9e06e9e.tar.gz Doxygen-cc52853c15833c9a18be11c140b99d94d9e06e9e.tar.bz2 |
Release-1.5.1-20070315
Diffstat (limited to 'qtools')
-rw-r--r-- | qtools/qcstring.cpp | 2 | ||||
-rw-r--r-- | qtools/qcstring.h | 1 | ||||
-rw-r--r-- | qtools/scstring.cpp | 9 |
3 files changed, 10 insertions, 2 deletions
diff --git a/qtools/qcstring.cpp b/qtools/qcstring.cpp index 1bd7c7f..e0e53e4 100644 --- a/qtools/qcstring.cpp +++ b/qtools/qcstring.cpp @@ -58,7 +58,7 @@ QCString::QCString( const char *str, uint maxlen ) if (str && ( l = QMIN(qstrlen(str),maxlen) )) { m_data=(char *)malloc(l+1); - strncpy(m_data,str,maxlen); + strncpy(m_data,str,l+1); m_data[l]='\0'; } else diff --git a/qtools/qcstring.h b/qtools/qcstring.h index e56b1e4..8df3bfd 100644 --- a/qtools/qcstring.h +++ b/qtools/qcstring.h @@ -50,6 +50,7 @@ #include <strings.h> #endif + class QGString; /***************************************************************************** diff --git a/qtools/scstring.cpp b/qtools/scstring.cpp index 18a5492..5632f57 100644 --- a/qtools/scstring.cpp +++ b/qtools/scstring.cpp @@ -13,10 +13,17 @@ * */ +// with this switch you can choose between the original qcstring implementation, +// which implicitly shares data so copying is faster, but requires at least 12 bytes, and +// the new implementation in this file, which has a smaller footprint (only 4 bytes for +// an empty string), but always copies strings. +#define SMALLSTRING + #include "qcstring.h" #ifndef SMALLSTRING #include "qcstring.cpp" #else +#define SCString QCString #include <qstring.h> #include <stdlib.h> @@ -60,7 +67,7 @@ SCString::SCString( const char *str, uint maxlen ) if (str && ( l = QMIN(qstrlen(str),maxlen) )) { m_data=(char *)malloc(l+1); - strncpy(m_data,str,maxlen); + strncpy(m_data,str,l+1); m_data[l]='\0'; } else |