cleanup for valgrind.
This commit is contained in:
parent
0ebe8eaf5b
commit
cfd996fe5a
2
File.h
2
File.h
@ -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();
|
||||
|
11
ZString.cpp
11
ZString.cpp
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user