is safe to deallocate a NULL pointer

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@115 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
satbaby
2009-12-22 15:39:54 +00:00
parent e53b3e76d7
commit 148c0a771a

View File

@@ -264,10 +264,12 @@ CFrameBuffer::~CFrameBuffer()
{ {
if (background) { if (background) {
delete[] background; delete[] background;
background = NULL;
} }
if (backupBackground) { if (backupBackground) {
delete[] backupBackground; delete[] backupBackground;
backupBackground = NULL;
} }
#if 0 #if 0
@@ -285,8 +287,10 @@ CFrameBuffer::~CFrameBuffer()
if (lfb) if (lfb)
munmap(lfb, available); munmap(lfb, available);
if (virtual_fb) if (virtual_fb){
delete[] virtual_fb; delete[] virtual_fb;
virtual_fb = NULL;
}
close(fd); close(fd);
close(tty); close(tty);
} }
@@ -1286,9 +1290,10 @@ bool CFrameBuffer::loadBackgroundPic(const std::string & filename, bool show)
return true; return true;
//printf("loadBackgroundPic: %s\n", filename.c_str()); //printf("loadBackgroundPic: %s\n", filename.c_str());
if (background) if (background){
delete[] background; delete[] background;
background = NULL;
}
background = g_PicViewer->getImage(iconBasePath + filename, BACKGROUNDIMAGEWIDTH, 576); background = g_PicViewer->getImage(iconBasePath + filename, BACKGROUNDIMAGEWIDTH, 576);
if (background == NULL) { if (background == NULL) {
@@ -1320,9 +1325,10 @@ bool CFrameBuffer::getuseBackground(void)
void CFrameBuffer::saveBackgroundImage(void) void CFrameBuffer::saveBackgroundImage(void)
{ {
if (backupBackground != NULL) if (backupBackground != NULL){
delete[] backupBackground; delete[] backupBackground;
backupBackground = NULL;
}
backupBackground = background; backupBackground = background;
//useBackground(false); // <- necessary since no background is available //useBackground(false); // <- necessary since no background is available
useBackgroundPaint = false; useBackgroundPaint = false;
@@ -1341,8 +1347,10 @@ void CFrameBuffer::restoreBackgroundImage(void)
else else
useBackground(false); // <- necessary since no background is available useBackground(false); // <- necessary since no background is available
if (tmp != NULL) if (tmp != NULL){
delete[] tmp; delete[] tmp;
tmp = NULL;
}
} }
void CFrameBuffer::paintBackgroundBoxRel(int x, int y, int dx, int dy) void CFrameBuffer::paintBackgroundBoxRel(int x, int y, int dx, int dy)