Revert previous commit (r3889). Windows code has to be cleaned before this
change.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3890 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index 7935a3a..a50ea58 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -35,19 +35,6 @@
#endif
#include <rfb/util.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-char* safe_strdup(const char* s) {
- char *tmp;
-
- tmp = strdup(s);
- if (tmp == NULL) {
- perror("safe_strdup failed");
- exit(1);
- }
-};
// Provide strcasecmp() and/or strncasecmp() if absent on this system.
@@ -142,6 +129,19 @@
namespace rfb {
+ char* strDup(const char* s) {
+ if (!s) return 0;
+ int l = strlen(s);
+ char* r = new char[l+1];
+ memcpy(r, s, l+1);
+ return r;
+ };
+
+ void strFree(char* s) {
+ delete [] s;
+ }
+
+
bool strSplit(const char* src, const char limiter, char** out1, char** out2, bool fromEnd) {
CharArray out1old, out2old;
if (out1) out1old.buf = *out1;
@@ -167,7 +167,7 @@
}
i+=increment;
}
- if (out1) *out1 = safe_strdup(src);
+ if (out1) *out1 = strDup(src);
if (out2) *out2 = 0;
return false;
}