summaryrefslogtreecommitdiffstats
path: root/qtools/qgstring.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2010-05-07 19:37:33 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2010-05-07 19:37:33 (GMT)
commita3b06c4fd310fdeda48a4730139cee09b5302072 (patch)
tree58636054e8f52c5851109b908053cc4da26b060a /qtools/qgstring.cpp
parent368c93a05bf38e440dba3f033f6e2e1cbeb2f379 (diff)
downloadDoxygen-a3b06c4fd310fdeda48a4730139cee09b5302072.zip
Doxygen-a3b06c4fd310fdeda48a4730139cee09b5302072.tar.gz
Doxygen-a3b06c4fd310fdeda48a4730139cee09b5302072.tar.bz2
Release-1.6.3-20100507
Diffstat (limited to 'qtools/qgstring.cpp')
-rw-r--r--qtools/qgstring.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/qtools/qgstring.cpp b/qtools/qgstring.cpp
index f43cd6b..f42eede 100644
--- a/qtools/qgstring.cpp
+++ b/qtools/qgstring.cpp
@@ -22,6 +22,7 @@
#define ROUND_SIZE(x) ((x)+BLOCK_SIZE-1)&~(BLOCK_SIZE-1)
#define DBG_STR(x) do { } while(0)
+//#define DBG_STR(x) printf x
QGString::QGString() // make null string
: m_data(0), m_len(0), m_memSize(0)
@@ -123,6 +124,40 @@ bool QGString::resize( uint newlen )
return TRUE;
}
+bool QGString::enlarge( uint newlen )
+{
+ if (newlen==0)
+ {
+ if (m_data) { free(m_data); m_data=0; }
+ m_memSize=0;
+ m_len=0;
+ return TRUE;
+ }
+ uint newMemSize = ROUND_SIZE(newlen+1);
+ if (newMemSize==m_memSize) return TRUE;
+ m_memSize = newMemSize;
+ if (m_data==0)
+ {
+ m_data = (char *)malloc(m_memSize);
+ }
+ else
+ {
+ m_data = (char *)realloc(m_data,m_memSize);
+ }
+ if (m_data==0)
+ {
+ return FALSE;
+ }
+ m_data[newlen-1]='\0';
+ if (m_len>newlen) m_len=newlen;
+ return TRUE;
+}
+
+void QGString::setLen( uint newlen )
+{
+ m_len = newlen<=m_memSize ? newlen : m_memSize;
+}
+
QGString &QGString::operator=( const QGString &s )
{
if (m_data) free(m_data);