Fixed potential memory leak and other minor problems with APP_INIT_DATA

structure.

svn path=/trunk/boinc/; revision=15886
This commit is contained in:
Eric J. Korpela 2008-08-19 00:08:01 +00:00
parent 17cd1c5f19
commit a782d6bc83
3 changed files with 16 additions and 7 deletions

View File

@ -6779,3 +6779,10 @@ Rom & Charlie 18 Aug 2008
clientscr/
screensaver.cpp
Eric 18 Aug 2008
- Fixed potential memory leak and other minor problems with
APP_INIT_DATA.
lib/
app_ipc.[Ch]

View File

@ -48,8 +48,7 @@ GRAPHICS_MSG::GRAPHICS_MSG() {
memset(this, 0, sizeof(GRAPHICS_MSG));
}
APP_INIT_DATA::APP_INIT_DATA() {
project_preferences = 0;
APP_INIT_DATA::APP_INIT_DATA() : project_preferences(NULL) {
}
APP_INIT_DATA::~APP_INIT_DATA() {
@ -63,8 +62,11 @@ APP_INIT_DATA::APP_INIT_DATA(const APP_INIT_DATA& a) {
copy(a);
}
void APP_INIT_DATA::operator=(const APP_INIT_DATA& a) {
APP_INIT_DATA &APP_INIT_DATA::operator=(const APP_INIT_DATA& a) {
if (this != &a) {
copy(a);
}
return *this;
}
void APP_INIT_DATA::copy(const APP_INIT_DATA& a) {
@ -253,9 +255,9 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) {
return ERR_XML_PARSE;
}
APP_CLIENT_SHM::APP_CLIENT_SHM() {
shm = 0;
APP_CLIENT_SHM::APP_CLIENT_SHM() : shm(NULL) {
}
bool MSG_CHANNEL::get_msg(char *msg) {
if (!buf[0]) return false;
strlcpy(msg, buf+1, MSG_CHANNEL_SIZE-1);

View File

@ -192,7 +192,7 @@ struct APP_INIT_DATA {
APP_INIT_DATA();
APP_INIT_DATA(const APP_INIT_DATA&); // copy constructor
void operator=(const APP_INIT_DATA&);
APP_INIT_DATA &operator=(const APP_INIT_DATA&);
void copy(const APP_INIT_DATA&); // actually do the copy here
~APP_INIT_DATA();
};