From 4293dc42f60fff4542162deba616ec99b2d9fd09 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 23 Jan 2023 19:55:20 +0100 Subject: Remove custom CharArray type It has now been replaced, mostly by std::string, so remove the actual type definition. --- common/rfb/Hostname.h | 1 + common/rfb/PixelBuffer.cxx | 2 ++ common/rfb/util.cxx | 24 +----------------------- common/rfb/util.h | 24 ------------------------ 4 files changed, 4 insertions(+), 47 deletions(-) (limited to 'common') diff --git a/common/rfb/Hostname.h b/common/rfb/Hostname.h index 8e57f31d..1971e343 100644 --- a/common/rfb/Hostname.h +++ b/common/rfb/Hostname.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx index dedae3b2..28eea9a7 100644 --- a/common/rfb/PixelBuffer.cxx +++ b/common/rfb/PixelBuffer.cxx @@ -26,6 +26,8 @@ #include #endif +#include + #include #include #include diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx index c5eeed92..0df9e1e3 100644 --- a/common/rfb/util.cxx +++ b/common/rfb/util.cxx @@ -25,35 +25,13 @@ #include #include #include +#include #include #include namespace rfb { - void CharArray::format(const char *fmt, ...) { - va_list ap; - int len; - - va_start(ap, fmt); - len = vsnprintf(NULL, 0, fmt, ap); - va_end(ap); - - delete [] buf; - - if (len < 0) { - buf = new char[1]; - buf[0] = '\0'; - return; - } - - buf = new char[len+1]; - - va_start(ap, fmt); - vsnprintf(buf, len+1, fmt, ap); - va_end(ap); - } - char* strDup(const char* s) { if (!s) return 0; int l = strlen(s); diff --git a/common/rfb/util.h b/common/rfb/util.h index b361aa11..799e0756 100644 --- a/common/rfb/util.h +++ b/common/rfb/util.h @@ -25,7 +25,6 @@ #define __RFB_UTIL_H__ #include -#include #include #include @@ -35,29 +34,6 @@ struct timeval; namespace rfb { - // -=- Class to handle cleanup of arrays of characters - class CharArray { - public: - CharArray() : buf(0) {} - CharArray(char* str) : buf(str) {} // note: assumes ownership - CharArray(size_t len) { - buf = new char[len](); - memset(buf, 0, len); - } - ~CharArray() { - delete [] buf; - } - void format(const char *fmt, ...) - __attribute__((__format__ (__printf__, 2, 3))); - // Get the buffer pointer & clear it (i.e. caller takes ownership) - char* takeBuf() {char* tmp = buf; buf = 0; return tmp;} - void replaceBuf(char* b) {delete [] buf; buf = b;} - char* buf; - private: - CharArray(const CharArray&); - CharArray& operator=(const CharArray&); - }; - char* strDup(const char* s); void strFree(char* s); -- cgit v1.2.3