cleanup for valgrind.

This commit is contained in:
barant 2024-12-23 11:15:53 -08:00
parent e5bfd7a840
commit 0ebe8eaf5b
3 changed files with 15 additions and 9 deletions

View File

@ -34,7 +34,7 @@ namespace coreutils {
File::~File() {
close(fd);
setBufferSize(0);
free(buffer);
}
void File::setBufferSize(size_t size) {

View File

@ -66,9 +66,11 @@ namespace coreutils {
}
ZString::~ZString() {
if(cdata != NULL)
if(cdata != NULL) {
std::cout << "********" << cdata << "********" << strlen(cdata) << std::endl;
free(cdata);
}
}
bool ZString::operator<(const ZString &valuex) const {
char *end1 = data + length;
@ -443,8 +445,12 @@ namespace coreutils {
}
int ZString::skipWhitespace() {
int len = strspn(cursor, " \n\t");
cursor += len;
char *end = data + length;
int len = 0;
while((cursor < end) && ((*cursor == ' ') || (*cursor == '\n') || (*cursor == '\t'))) {
++cursor;
++len;
}
return len;
}

View File

@ -84,7 +84,7 @@ namespace coreutils {
/// Destructor for the ZString.
///
~ZString();
virtual ~ZString();
///
/// A friend method used to write the value of the ZString
@ -454,9 +454,9 @@ namespace coreutils {
void moveBackToLineStart();
protected:
char *data;
char *cursor;
size_t length;
char *data = NULL;
char *cursor = NULL;
size_t length = 0;
char *cdata = NULL;
std::vector<ZString> list;