aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2004-04-02 11:33:55 +0000
committernyamatongwe <unknown>2004-04-02 11:33:55 +0000
commitb745b468bb0d82b3406b86325f69d18d7cf791c2 (patch)
tree94c976ec45aeaee9d82a43f8a37fe1a52125e9d2
parent9cdfd99f604c738656504beb18ebe6c7dd8ba99c (diff)
downloadscintilla-mirror-b745b468bb0d82b3406b86325f69d18d7cf791c2.tar.gz
String code from Pavol Bosik used by Anjuta.
-rw-r--r--doc/ScintillaHistory.html1
-rw-r--r--include/SString.h17
-rw-r--r--src/PropSet.cxx13
3 files changed, 29 insertions, 2 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 22aaef54a..4b0ed96d9 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -167,6 +167,7 @@
<li>Reinhold Niesner</li>
<li>Jos van der Zande</li>
<li>Pescuma</li>
+ <li>Pavol Bosik</li>
</ul>
<p>
Images used in GTK+ version
diff --git a/include/SString.h b/include/SString.h
index 3efb84a03..960945dbc 100644
--- a/include/SString.h
+++ b/include/SString.h
@@ -109,6 +109,18 @@ public:
const char *c_str() const {
return s ? s : "";
}
+ /** Attach to a string allocated by means of StringAlloc(len). */
+ SString &attach(char *s_, lenpos_t sLen_ = measure_length, lenpos_t sSize_ = measure_length) {
+ delete []s;
+ s = s_;
+ if (!s) {
+ sLen = sSize = 0;
+ } else {
+ sLen = (sLen_ == measure_length ? strlen(s) : sLen_);
+ sSize = (sSize_ == measure_length ? sLen + 1 : sSize_);
+ }
+ return *this;
+ }
/** Give ownership of buffer to caller which must use delete[] to free buffer. */
char *detach() {
char *sRet = s;
@@ -175,6 +187,11 @@ public:
static char *StringAllocate(
const char *s, ///< The string to duplicate
lenpos_t len=measure_length); ///< The length of memory to allocate. Optional.
+ /**
+ * Allocate uninitialized memory big enough to fit a string of the given length
+ * @return the pointer to the new string
+ */
+ static char *StringAllocate(lenpos_t len);
};
/**
diff --git a/src/PropSet.cxx b/src/PropSet.cxx
index 32ec59626..70cd46f88 100644
--- a/src/PropSet.cxx
+++ b/src/PropSet.cxx
@@ -325,9 +325,18 @@ char *SString::StringAllocate(
return sNew;
}
-// End SString functions
-
+/**
+ * Allocate uninitialized memory big enough to fit a string of the given length
+ * @return the pointer to the new string
+ */
+char *SString::StringAllocate(lenpos_t len) {
+ if (len != measure_length)
+ return new char [len + 1];
+ else
+ return 0;
+}
+// End SString functions
PropSet::PropSet() {
superPS = 0;