summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-08-11 13:32:23 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2002-08-11 13:32:23 +0200
commit9a1a16f3d42b2f48b26eb3daef3a195fc0f2a13e (patch)
tree7d7d8667832651e37cd8de53296d0bcd32dba085 /tools.c
parentb9c4cb0ec9c417c483be2a40cd66f839b063015f (diff)
downloadvdr-9a1a16f3d42b2f48b26eb3daef3a195fc0f2a13e.tar.gz
vdr-9a1a16f3d42b2f48b26eb3daef3a195fc0f2a13e.tar.bz2
Consistently using malloc/free and new/delete
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/tools.c b/tools.c
index 6449a1be..40aad70a 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.68 2002/08/03 15:44:53 kls Exp $
+ * $Id: tools.c 1.69 2002/08/11 11:49:08 kls Exp $
*/
#include "tools.h"
@@ -80,7 +80,7 @@ char *strcpyrealloc(char *dest, const char *src)
esyslog("ERROR: out of memory");
}
else {
- delete dest;
+ free(dest);
dest = NULL;
}
return dest;
@@ -239,7 +239,7 @@ bool isnumber(const char *s)
const char *AddDirectory(const char *DirName, const char *FileName)
{
static char *buf = NULL;
- delete buf;
+ free(buf);
asprintf(&buf, "%s/%s", DirName && *DirName ? DirName : ".", FileName);
return buf;
}
@@ -303,7 +303,7 @@ bool MakeDirs(const char *FileName, bool IsDirectory)
else
break;
}
- delete s;
+ free(s);
return result;
}
@@ -321,7 +321,7 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
asprintf(&buffer, "%s/%s", FileName, e->d_name);
if (FollowSymlinks) {
int size = strlen(buffer) * 2; // should be large enough
- char *l = new char[size];
+ char *l = MALLOC(char, size);
int n = readlink(buffer, l, size);
if (n < 0) {
if (errno != EINVAL)
@@ -335,12 +335,12 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
}
else
esyslog("ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
- delete l;
+ free(l);
}
dsyslog("removing %s", buffer);
if (remove(buffer) < 0)
LOG_ERROR_STR(buffer);
- delete buffer;
+ free(buffer);
}
}
closedir(d);
@@ -384,10 +384,10 @@ bool RemoveEmptyDirectories(const char *DirName, bool RemoveThis)
}
else {
LOG_ERROR_STR(buffer);
- delete buffer;
+ free(buffer);
return false;
}
- delete buffer;
+ free(buffer);
}
}
closedir(d);
@@ -429,7 +429,7 @@ bool SpinUpDisk(const char *FileName)
{
static char *buf = NULL;
for (int n = 0; n < 10; n++) {
- delete buf;
+ free(buf);
if (DirectoryOk(FileName))
asprintf(&buf, "%s/vdr-%06d", *FileName ? FileName : ".", n);
else
@@ -594,7 +594,7 @@ cSafeFile::cSafeFile(const char *FileName)
{
f = NULL;
fileName = ReadLink(FileName);
- tempName = fileName ? new char[strlen(fileName) + 5] : NULL;
+ tempName = fileName ? MALLOC(char, strlen(fileName) + 5) : NULL;
if (tempName)
strcat(strcpy(tempName, fileName), ".$$$");
}
@@ -604,8 +604,8 @@ cSafeFile::~cSafeFile()
if (f)
fclose(f);
unlink(tempName);
- delete fileName;
- delete tempName;
+ free(fileName);
+ free(tempName);
}
bool cSafeFile::Open(void)
@@ -657,7 +657,7 @@ cLockFile::cLockFile(const char *Directory)
cLockFile::~cLockFile()
{
Unlock();
- delete fileName;
+ free(fileName);
}
bool cLockFile::Lock(int WaitSeconds)