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
+7 -6

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();
+6 -5
View File
@@ -66,10 +66,8 @@ namespace coreutils {
}
ZString::~ZString() {
if(cdata != NULL) {
std::cout << "********" << cdata << "********" << strlen(cdata) << std::endl;
free(cdata);
}
if(cdata != NULL)
free(cdata);
}
bool ZString::operator<(const ZString &valuex) const {
@@ -234,7 +232,10 @@ namespace coreutils {
}
char* ZString::c_str() {
cdata = (char *)malloc(length + 1);
if(cdata == NULL)
cdata = (char *)malloc(length + 1);
else
cdata = (char *)realloc(cdata, length + 1);
strncpy(cdata, data, length);
cdata[length] = '\0';
return cdata;