cleanup for valgrind.

This commit is contained in:
barant committed 2024-12-23 13:00:22 -08:00
1 parent 0ebe8eaf5b
commit cfd996fe5a
2 files changed
+5 -4

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ namespace coreutils {
public:
File(ZString fileName, int mode = O_RDONLY, int authority = 0664);
~File();
virtual ~File();
void setBufferSize(size_t size);
int read();
int readLine();
+4 -3
View File
@@ -66,11 +66,9 @@ namespace coreutils {
}
ZString::~ZString() {
if(cdata != NULL) {
std::cout << "********" << cdata << "********" << strlen(cdata) << std::endl;
if(cdata != NULL)
free(cdata);
}
}
bool ZString::operator<(const ZString &valuex) const {
char *end1 = data + length;
@@ -234,7 +232,10 @@ namespace coreutils {
}
char* ZString::c_str() {
if(cdata == NULL)
cdata = (char *)malloc(length + 1);
else
cdata = (char *)realloc(cdata, length + 1);
strncpy(cdata, data, length);
cdata[length] = '\0';
return cdata;