1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Consistently using malloc/free and new/delete

This commit is contained in:
Klaus Schmidinger 2002-08-11 13:32:23 +02:00
parent b9c4cb0ec9
commit 9a1a16f3d4
23 changed files with 172 additions and 160 deletions

View File

@ -158,6 +158,7 @@ Andreas Schultz <aschultz@warp10.net>
than 3 characters than 3 characters
for adding direct access to the index data of cPalette (needed for displaying SPUs) for adding direct access to the index data of cPalette (needed for displaying SPUs)
for pointing out a possible race condition in the cDvbPlayer for pointing out a possible race condition in the cDvbPlayer
for making the use of malloc/free and new/delete consistent
Aaron Holtzman Aaron Holtzman
for writing 'ac3dec' for writing 'ac3dec'

View File

@ -1401,3 +1401,4 @@ Video Disk Recorder Revision History
- Added some missing #includes (thanks to Martin Hammerschmid). - Added some missing #includes (thanks to Martin Hammerschmid).
- Changed the log error message "can't record MPEG1!" to "error in data stream!", - Changed the log error message "can't record MPEG1!" to "error in data stream!",
since the mentioning of MPEG1 has irritated many people. since the mentioning of MPEG1 has irritated many people.
- Consistently using malloc/free and new/delete (thanks to Andreas Schultz).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: config.c 1.103 2002/08/04 12:03:11 kls Exp $ * $Id: config.c 1.104 2002/08/11 11:35:18 kls Exp $
*/ */
#include "config.h" #include "config.h"
@ -217,7 +217,7 @@ const char *cChannel::ToText(cChannel *Channel)
s = strcpy(buf, s); s = strcpy(buf, s);
strreplace(s, ':', '|'); strreplace(s, ':', '|');
} }
delete buffer; free(buffer);
if (Channel->groupSep) if (Channel->groupSep)
asprintf(&buffer, ":%s\n", s); asprintf(&buffer, ":%s\n", s);
else { else {
@ -267,7 +267,7 @@ bool cChannel::Parse(const char *s)
sscanf(apidbuf, "%d ,%d ", &apid1, &apid2); sscanf(apidbuf, "%d ,%d ", &apid1, &apid2);
if (p) if (p)
sscanf(p, "%d ,%d ", &dpid1, &dpid2); sscanf(p, "%d ,%d ", &dpid1, &dpid2);
delete apidbuf; free(apidbuf);
} }
else else
return false; return false;
@ -279,7 +279,7 @@ bool cChannel::Parse(const char *s)
tpid = 0; tpid = 0;
} }
strn0cpy(name, buffer, MaxChannelName); strn0cpy(name, buffer, MaxChannelName);
delete buffer; free(buffer);
} }
else else
return false; return false;
@ -377,7 +377,7 @@ cTimer::cTimer(const cEventInfo *EventInfo)
cTimer::~cTimer() cTimer::~cTimer()
{ {
delete summary; free(summary);
} }
cTimer& cTimer::operator= (const cTimer &Timer) cTimer& cTimer::operator= (const cTimer &Timer)
@ -398,7 +398,7 @@ bool cTimer::operator< (const cListObject &ListObject)
const char *cTimer::ToText(cTimer *Timer) const char *cTimer::ToText(cTimer *Timer)
{ {
delete buffer; free(buffer);
strreplace(Timer->file, ':', '|'); strreplace(Timer->file, ':', '|');
strreplace(Timer->summary, '\n', '|'); strreplace(Timer->summary, '\n', '|');
asprintf(&buffer, "%d:%d:%s:%04d:%04d:%d:%d:%s:%s\n", Timer->active, Timer->channel, PrintDay(Timer->day, Timer->firstday), Timer->start, Timer->stop, Timer->priority, Timer->lifetime, Timer->file, Timer->summary ? Timer->summary : ""); asprintf(&buffer, "%d:%d:%s:%04d:%04d:%d:%d:%s:%s\n", Timer->active, Timer->channel, PrintDay(Timer->day, Timer->firstday), Timer->start, Timer->stop, Timer->priority, Timer->lifetime, Timer->file, Timer->summary ? Timer->summary : "");
@ -495,7 +495,7 @@ bool cTimer::Parse(const char *s)
{ {
char *buffer1 = NULL; char *buffer1 = NULL;
char *buffer2 = NULL; char *buffer2 = NULL;
delete summary; free(summary);
summary = NULL; summary = NULL;
//XXX Apparently sscanf() doesn't work correctly if the last %a argument //XXX Apparently sscanf() doesn't work correctly if the last %a argument
//XXX results in an empty string (this first occured when the EIT gathering //XXX results in an empty string (this first occured when the EIT gathering
@ -508,13 +508,13 @@ bool cTimer::Parse(const char *s)
while (l2 > 0 && isspace(s[l2 - 1])) while (l2 > 0 && isspace(s[l2 - 1]))
l2--; l2--;
if (s[l2 - 1] == ':') { if (s[l2 - 1] == ':') {
s2 = (char *)malloc(l2 + 3); s2 = MALLOC(char, l2 + 3);
strcat(strn0cpy(s2, s, l2 + 1), " \n"); strcat(strn0cpy(s2, s, l2 + 1), " \n");
s = s2; s = s2;
} }
if (8 <= sscanf(s, "%d :%d :%a[^:]:%d :%d :%d :%d :%a[^:\n]:%a[^\n]", &active, &channel, &buffer1, &start, &stop, &priority, &lifetime, &buffer2, &summary)) { if (8 <= sscanf(s, "%d :%d :%a[^:]:%d :%d :%d :%d :%a[^:\n]:%a[^\n]", &active, &channel, &buffer1, &start, &stop, &priority, &lifetime, &buffer2, &summary)) {
if (summary && !*skipspace(summary)) { if (summary && !*skipspace(summary)) {
delete summary; free(summary);
summary = NULL; summary = NULL;
} }
//TODO add more plausibility checks //TODO add more plausibility checks
@ -522,12 +522,12 @@ bool cTimer::Parse(const char *s)
strn0cpy(file, buffer2, MaxFileName); strn0cpy(file, buffer2, MaxFileName);
strreplace(file, '|', ':'); strreplace(file, '|', ':');
strreplace(summary, '|', '\n'); strreplace(summary, '|', '\n');
delete buffer1; free(buffer1);
delete buffer2; free(buffer2);
delete s2; free(s2);
return day != 0; return day != 0;
} }
delete s2; free(s2);
return false; return false;
} }
@ -661,8 +661,8 @@ cCommand::cCommand(void)
cCommand::~cCommand() cCommand::~cCommand()
{ {
delete title; free(title);
delete command; free(command);
} }
bool cCommand::Parse(const char *s) bool cCommand::Parse(const char *s)
@ -685,7 +685,7 @@ bool cCommand::Parse(const char *s)
const char *cCommand::Execute(void) const char *cCommand::Execute(void)
{ {
dsyslog("executing command '%s'", command); dsyslog("executing command '%s'", command);
delete result; free(result);
result = NULL; result = NULL;
FILE *p = popen(command, "r"); FILE *p = popen(command, "r");
if (p) { if (p) {
@ -749,7 +749,7 @@ cCaDefinition::cCaDefinition(void)
cCaDefinition::~cCaDefinition() cCaDefinition::~cCaDefinition()
{ {
delete description; free(description);
} }
bool cCaDefinition::Parse(const char *s) bool cCaDefinition::Parse(const char *s)
@ -935,9 +935,9 @@ cSetupLine::cSetupLine(const char *Name, const char *Value, const char *Plugin)
cSetupLine::~cSetupLine() cSetupLine::~cSetupLine()
{ {
delete plugin; free(plugin);
delete name; free(name);
delete value; free(value);
} }
bool cSetupLine::operator< (const cListObject &ListObject) bool cSetupLine::operator< (const cListObject &ListObject)
@ -1068,7 +1068,7 @@ void cSetup::Store(const char *Name, int Value, const char *Plugin)
char *buffer = NULL; char *buffer = NULL;
asprintf(&buffer, "%d", Value); asprintf(&buffer, "%d", Value);
Store(Name, buffer, Plugin); Store(Name, buffer, Plugin);
delete buffer; free(buffer);
} }
bool cSetup::Load(const char *FileName) bool cSetup::Load(const char *FileName)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: config.h 1.122 2002/08/09 14:53:21 kls Exp $ * $Id: config.h 1.123 2002/08/11 11:36:36 kls Exp $
*/ */
#ifndef __CONFIG_H #ifndef __CONFIG_H
@ -12,6 +12,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -214,12 +215,13 @@ private:
char *fileName; char *fileName;
void Clear(void) void Clear(void)
{ {
delete fileName; free(fileName);
fileName = NULL;
cList<T>::Clear(); cList<T>::Clear();
} }
public: public:
cConfig(void) { fileName = NULL; } cConfig(void) { fileName = NULL; }
virtual ~cConfig() { delete fileName; } virtual ~cConfig() { free(fileName); }
const char *FileName(void) { return fileName; } const char *FileName(void) { return fileName; }
bool Load(const char *FileName, bool AllowComments = false) bool Load(const char *FileName, bool AllowComments = false)
{ {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: cutter.c 1.1 2002/06/22 10:09:34 kls Exp $ * $Id: cutter.c 1.2 2002/08/11 11:09:23 kls Exp $
*/ */
#include "cutter.h" #include "cutter.h"
@ -196,7 +196,7 @@ bool cCutter::Start(const char *FileName)
RemoveVideoFile(s); RemoveVideoFile(s);
} }
} }
delete s; free(s);
// XXX // XXX
editedVersionName = strdup(evn); editedVersionName = strdup(evn);
Recording.WriteSummary(); Recording.WriteSummary();
@ -231,7 +231,7 @@ bool cCutter::Active(void)
Stop(); Stop();
if (!error) if (!error)
cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName); cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName);
delete editedVersionName; free(editedVersionName);
editedVersionName = NULL; editedVersionName = NULL;
ended = true; ended = true;
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbdevice.c 1.2 2002/08/10 14:57:33 kls Exp $ * $Id: dvbdevice.c 1.3 2002/08/11 12:03:33 kls Exp $
*/ */
#include "dvbdevice.h" #include "dvbdevice.h"
@ -316,6 +316,7 @@ bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
if (Handle->pid != 0x1FFF) { if (Handle->pid != 0x1FFF) {
dmxPesFilterParams pesFilterParams; dmxPesFilterParams pesFilterParams;
memset(&pesFilterParams, 0, sizeof(pesFilterParams));
pesFilterParams.pid = Handle->pid; pesFilterParams.pid = Handle->pid;
pesFilterParams.input = DMX_IN_FRONTEND; pesFilterParams.input = DMX_IN_FRONTEND;
pesFilterParams.output = (Type <= ptTeletext && Handle->used <= 1) ? DMX_OUT_DECODER : DMX_OUT_TS_TAP; pesFilterParams.output = (Type <= ptTeletext && Handle->used <= 1) ? DMX_OUT_DECODER : DMX_OUT_TS_TAP;
@ -364,6 +365,8 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel)
FrontendParameters Frontend; FrontendParameters Frontend;
#endif #endif
memset(&Frontend, 0, sizeof(Frontend));
switch (frontendType) { switch (frontendType) {
case FE_QPSK: { // DVB-S case FE_QPSK: { // DVB-S

18
eit.c
View File

@ -16,7 +16,7 @@
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* $Id: eit.c 1.47 2002/08/09 16:17:14 kls Exp $ * $Id: eit.c 1.48 2002/08/11 11:11:12 kls Exp $
***************************************************************************/ ***************************************************************************/
#include "eit.h" #include "eit.h"
@ -202,9 +202,9 @@ cEventInfo::cEventInfo(unsigned short serviceid, unsigned short eventid)
cEventInfo::~cEventInfo() cEventInfo::~cEventInfo()
{ {
delete pTitle; free(pTitle);
delete pSubtitle; free(pSubtitle);
delete pExtendedDescription; free(pExtendedDescription);
} }
/** */ /** */
@ -500,8 +500,8 @@ void cEventInfo::FixEpgBugs(void)
*e = 0; *e = 0;
char *s = strdup(p + 1); char *s = strdup(p + 1);
char *d = strdup(e + strlen(delim)); char *d = strdup(e + strlen(delim));
delete pSubtitle; free(pSubtitle);
delete pExtendedDescription; free(pExtendedDescription);
pSubtitle = s; pSubtitle = s;
pExtendedDescription = d; pExtendedDescription = d;
EpgBugFixStat(0, GetServiceID()); EpgBugFixStat(0, GetServiceID());
@ -531,7 +531,7 @@ void cEventInfo::FixEpgBugs(void)
// Title // Title
// //
if (pSubtitle && strcmp(pTitle, pSubtitle) == 0) { if (pSubtitle && strcmp(pTitle, pSubtitle) == 0) {
delete pSubtitle; free(pSubtitle);
pSubtitle = NULL; pSubtitle = NULL;
EpgBugFixStat(2, GetServiceID()); EpgBugFixStat(2, GetServiceID());
} }
@ -1001,10 +1001,10 @@ cSIProcessor::~cSIProcessor()
active = false; active = false;
Cancel(3); Cancel(3);
ShutDownFilters(); ShutDownFilters();
delete filters; free(filters);
if (!--numSIProcessors) // the last one deletes it if (!--numSIProcessors) // the last one deletes it
delete schedules; delete schedules;
delete fileName; free(fileName);
} }
const cSchedules *cSIProcessor::Schedules(cMutexLock &MutexLock) const cSchedules *cSIProcessor::Schedules(cMutexLock &MutexLock)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: eitscan.c 1.4 2002/07/28 15:10:23 kls Exp $ * $Id: eitscan.c 1.5 2002/08/11 11:11:39 kls Exp $
*/ */
#include "eitscan.h" #include "eitscan.h"
@ -21,7 +21,7 @@ cEITScanner::cEITScanner(void)
cEITScanner::~cEITScanner() cEITScanner::~cEITScanner()
{ {
delete transponders; free(transponders);
} }
bool cEITScanner::TransponderScanned(cChannel *Channel) bool cEITScanner::TransponderScanned(cChannel *Channel)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: interface.c 1.53 2002/08/11 10:47:04 kls Exp $ * $Id: interface.c 1.54 2002/08/11 11:46:47 kls Exp $
*/ */
#include "interface.h" #include "interface.h"
@ -85,7 +85,7 @@ eKeys cInterface::GetKey(bool Wait)
char *message = SVDRP->GetMessage(); char *message = SVDRP->GetMessage();
if (message) { if (message) {
Info(message); Info(message);
delete message; free(message);
} }
} }
} }
@ -214,12 +214,12 @@ char *cInterface::WrapText(const char *Text, int Width, int *Height)
// punch in a newline, so we need to make room for it: // punch in a newline, so we need to make room for it:
if (Delim) if (Delim)
p = Delim + 1; // let's fall back to the most recent delimiter p = Delim + 1; // let's fall back to the most recent delimiter
char *s = new char[strlen(t) + 2]; // The additional '\n' plus the terminating '\0' char *s = MALLOC(char, strlen(t) + 2); // The additional '\n' plus the terminating '\0'
int l = p - t; int l = p - t;
strncpy(s, t, l); strncpy(s, t, l);
s[l] = '\n'; s[l] = '\n';
strcpy(s + l + 1, p); strcpy(s + l + 1, p);
delete t; free(t);
t = s; t = s;
p = t + l; p = t + l;
continue; continue;
@ -400,7 +400,7 @@ void cInterface::QueryKeys(void)
char *Prompt; char *Prompt;
asprintf(&Prompt, tr("Press key for '%s'"), tr(k->name)); asprintf(&Prompt, tr("Press key for '%s'"), tr(k->name));
WriteText(1, 5, Prompt); WriteText(1, 5, Prompt);
delete Prompt; free(Prompt);
for (;;) { for (;;) {
unsigned int ch = GetCh(); unsigned int ch = GetCh();
if (ch != 0) { if (ch != 0) {

42
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.203 2002/08/03 09:55:44 kls Exp $ * $Id: menu.c 1.204 2002/08/11 11:50:20 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -936,7 +936,7 @@ cMenuEvent::cMenuEvent(const cEventInfo *EventInfo, bool CanSwitch)
char *buffer; char *buffer;
asprintf(&buffer, "%-17.*s\t%.*s %s - %s", 17, channel->name, 5, eventInfo->GetDate(), eventInfo->GetTimeString(), eventInfo->GetEndTimeString()); asprintf(&buffer, "%-17.*s\t%.*s %s - %s", 17, channel->name, 5, eventInfo->GetDate(), eventInfo->GetTimeString(), eventInfo->GetEndTimeString());
SetTitle(buffer, false); SetTitle(buffer, false);
delete buffer; free(buffer);
int Line = 2; int Line = 2;
cMenuTextItem *item; cMenuTextItem *item;
const char *Title = eventInfo->GetTitle(); const char *Title = eventInfo->GetTitle();
@ -1040,7 +1040,7 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentCha
Add(new cMenuWhatsOnItem(pArray[a]), pArray[a]->GetChannelNumber() == CurrentChannelNr); Add(new cMenuWhatsOnItem(pArray[a]), pArray[a]->GetChannelNumber() == CurrentChannelNr);
currentChannel = CurrentChannelNr; currentChannel = CurrentChannelNr;
delete pArray; free(pArray);
SetHelp(tr("Record"), Now ? tr("Next") : tr("Now"), tr("Button$Schedule"), tr("Switch")); SetHelp(tr("Record"), Now ? tr("Next") : tr("Now"), tr("Button$Schedule"), tr("Switch"));
} }
@ -1173,11 +1173,11 @@ void cMenuSchedule::PrepareSchedule(cChannel *Channel)
char *buffer = NULL; char *buffer = NULL;
asprintf(&buffer, tr("Schedule - %s"), Channel->name); asprintf(&buffer, tr("Schedule - %s"), Channel->name);
SetTitle(buffer); SetTitle(buffer);
delete buffer; free(buffer);
if (schedules) { if (schedules) {
const cSchedule *Schedule = Channel->pnr ? schedules->GetSchedule(Channel->pnr) : schedules->GetSchedule(); const cSchedule *Schedule = Channel->pnr ? schedules->GetSchedule(Channel->pnr) : schedules->GetSchedule();
int num = Schedule->NumEvents(); int num = Schedule->NumEvents();
const cEventInfo **pArray = (const cEventInfo **)malloc(num * sizeof(cEventInfo *)); const cEventInfo **pArray = MALLOC(const cEventInfo *, num);
if (pArray) { if (pArray) {
time_t now = time(NULL); time_t now = time(NULL);
int numreal = 0; int numreal = 0;
@ -1191,7 +1191,7 @@ void cMenuSchedule::PrepareSchedule(cChannel *Channel)
for (int a = 0; a < numreal; a++) for (int a = 0; a < numreal; a++)
Add(new cMenuScheduleItem(pArray[a])); Add(new cMenuScheduleItem(pArray[a]));
delete pArray; free(pArray);
} }
} }
} }
@ -1306,8 +1306,8 @@ cMenuRecordingItem::cMenuRecordingItem(cRecording *Recording, int Level)
cMenuRecordingItem::~cMenuRecordingItem() cMenuRecordingItem::~cMenuRecordingItem()
{ {
delete fileName; free(fileName);
delete name; free(name);
} }
void cMenuRecordingItem::IncrementCounter(bool New) void cMenuRecordingItem::IncrementCounter(bool New)
@ -1344,7 +1344,7 @@ cMenuRecordings::cMenuRecordings(const char *Base, int Level, bool OpenSubMenus)
if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText) != 0)) { if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText) != 0)) {
Add(Item); Add(Item);
LastItem = Item; LastItem = Item;
delete LastItemText; free(LastItemText);
LastItemText = strdup(LastItem->Text()); // must use a copy because of the counters! LastItemText = strdup(LastItem->Text()); // must use a copy because of the counters!
} }
else else
@ -1357,7 +1357,7 @@ cMenuRecordings::cMenuRecordings(const char *Base, int Level, bool OpenSubMenus)
} }
} }
} }
delete LastItemText; free(LastItemText);
if (Current() < 0) if (Current() < 0)
SetCurrent(First()); SetCurrent(First());
else if (OpenSubMenus && Open(true)) else if (OpenSubMenus && Open(true))
@ -1370,7 +1370,7 @@ cMenuRecordings::cMenuRecordings(const char *Base, int Level, bool OpenSubMenus)
cMenuRecordings::~cMenuRecordings() cMenuRecordings::~cMenuRecordings()
{ {
helpKeys = -1; helpKeys = -1;
delete base; free(base);
} }
void cMenuRecordings::SetHelpKeys(void) void cMenuRecordings::SetHelpKeys(void)
@ -1417,7 +1417,7 @@ bool cMenuRecordings::Open(bool OpenSubMenus)
t = buffer; t = buffer;
} }
AddSubMenu(new cMenuRecordings(t, level + 1, OpenSubMenus)); AddSubMenu(new cMenuRecordings(t, level + 1, OpenSubMenus));
delete buffer; free(buffer);
return true; return true;
} }
return false; return false;
@ -1766,7 +1766,7 @@ cMenuSetupPlugins::cMenuSetupPlugins(void)
char *buffer = NULL; char *buffer = NULL;
asprintf(&buffer, "%s (%s) - %s", p->Name(), p->Version(), p->Description()); asprintf(&buffer, "%s (%s) - %s", p->Name(), p->Version(), p->Description());
Add(new cMenuSetupPluginItem(hk(buffer), i)); Add(new cMenuSetupPluginItem(hk(buffer), i));
delete buffer; free(buffer);
} }
else else
break; break;
@ -1901,7 +1901,7 @@ eOSState cMenuCommands::Execute(void)
asprintf(&buffer, "%s...", command->Title()); asprintf(&buffer, "%s...", command->Title());
Interface->Status(buffer); Interface->Status(buffer);
Interface->Flush(); Interface->Flush();
delete buffer; free(buffer);
const char *Result = command->Execute(); const char *Result = command->Execute();
if (Result) if (Result)
return AddSubMenu(new cMenuText(command->Title(), Result, fontFix)); return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
@ -2013,7 +2013,7 @@ void cMenuMain::Set(void)
char *buffer = NULL; char *buffer = NULL;
asprintf(&buffer, "%s%s", STOP_RECORDING, ON_PRIMARY_INTERFACE); asprintf(&buffer, "%s%s", STOP_RECORDING, ON_PRIMARY_INTERFACE);
Add(new cOsdItem(buffer, osStopRecord)); Add(new cOsdItem(buffer, osStopRecord));
delete buffer; free(buffer);
} }
const char *s = NULL; const char *s = NULL;
@ -2021,7 +2021,7 @@ void cMenuMain::Set(void)
char *buffer = NULL; char *buffer = NULL;
asprintf(&buffer, "%s%s", STOP_RECORDING, s); asprintf(&buffer, "%s%s", STOP_RECORDING, s);
Add(new cOsdItem(buffer, osStopRecord)); Add(new cOsdItem(buffer, osStopRecord));
delete buffer; free(buffer);
} }
// Editing control: // Editing control:
@ -2452,8 +2452,8 @@ cRecordControl::cRecordControl(cDevice *Device, cTimer *Timer)
cRecordControl::~cRecordControl() cRecordControl::~cRecordControl()
{ {
Stop(true); Stop(true);
delete instantId; free(instantId);
delete fileName; free(fileName);
} }
#define INSTANT_REC_EPG_LOOKAHEAD 300 // seconds to look into the EPG data for an instant recording #define INSTANT_REC_EPG_LOOKAHEAD 300 // seconds to look into the EPG data for an instant recording
@ -2701,8 +2701,8 @@ cReplayControl::~cReplayControl()
void cReplayControl::SetRecording(const char *FileName, const char *Title) void cReplayControl::SetRecording(const char *FileName, const char *Title)
{ {
delete fileName; free(fileName);
delete title; free(title);
fileName = FileName ? strdup(FileName) : NULL; fileName = FileName ? strdup(FileName) : NULL;
title = Title ? strdup(Title) : NULL; title = Title ? strdup(Title) : NULL;
} }
@ -2715,7 +2715,7 @@ const char *cReplayControl::LastReplayed(void)
void cReplayControl::ClearLastReplayed(const char *FileName) void cReplayControl::ClearLastReplayed(const char *FileName)
{ {
if (fileName && FileName && strcmp(fileName, FileName) == 0) { if (fileName && FileName && strcmp(fileName, FileName) == 0) {
delete fileName; free(fileName);
fileName = NULL; fileName = NULL;
} }
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menuitems.c 1.6 2002/06/16 13:23:56 kls Exp $ * $Id: menuitems.c 1.7 2002/08/11 11:17:21 kls Exp $
*/ */
#include "menuitems.h" #include "menuitems.h"
@ -23,13 +23,13 @@ cMenuEditItem::cMenuEditItem(const char *Name)
cMenuEditItem::~cMenuEditItem() cMenuEditItem::~cMenuEditItem()
{ {
delete name; free(name);
delete value; free(value);
} }
void cMenuEditItem::SetValue(const char *Value) void cMenuEditItem::SetValue(const char *Value)
{ {
delete value; free(value);
value = strdup(Value); value = strdup(Value);
char *buffer = NULL; char *buffer = NULL;
asprintf(&buffer, "%s:\t%s", name, value); asprintf(&buffer, "%s:\t%s", name, value);
@ -119,7 +119,7 @@ cMenuEditChrItem::cMenuEditChrItem(const char *Name, char *Value, const char *Al
cMenuEditChrItem::~cMenuEditChrItem() cMenuEditChrItem::~cMenuEditChrItem()
{ {
delete allowed; free(allowed);
} }
void cMenuEditChrItem::Set(void) void cMenuEditChrItem::Set(void)
@ -167,7 +167,7 @@ cMenuEditStrItem::cMenuEditStrItem(const char *Name, char *Value, int Length, co
cMenuEditStrItem::~cMenuEditStrItem() cMenuEditStrItem::~cMenuEditStrItem()
{ {
delete allowed; free(allowed);
} }
void cMenuEditStrItem::SetHelpKeys(void) void cMenuEditStrItem::SetHelpKeys(void)
@ -364,7 +364,7 @@ cMenuTextItem::cMenuTextItem(const char *Text, int X, int Y, int W, int H, eDvbC
cMenuTextItem::~cMenuTextItem() cMenuTextItem::~cMenuTextItem()
{ {
delete text; free(text);
} }
void cMenuTextItem::Clear(void) void cMenuTextItem::Clear(void)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menuitems.h 1.2 2002/05/11 10:48:28 kls Exp $ * $Id: menuitems.h 1.3 2002/08/11 11:40:05 kls Exp $
*/ */
#ifndef __MENUITEMS_H #ifndef __MENUITEMS_H
@ -14,8 +14,8 @@
class cMenuEditItem : public cOsdItem { class cMenuEditItem : public cOsdItem {
private: private:
const char *name; char *name;
const char *value; char *value;
public: public:
cMenuEditItem(const char *Name); cMenuEditItem(const char *Name);
~cMenuEditItem(); ~cMenuEditItem();
@ -43,7 +43,7 @@ public:
class cMenuEditChrItem : public cMenuEditItem { class cMenuEditChrItem : public cMenuEditItem {
private: private:
char *value; char *value;
const char *allowed; char *allowed;
const char *current; const char *current;
virtual void Set(void); virtual void Set(void);
public: public:
@ -56,7 +56,7 @@ class cMenuEditStrItem : public cMenuEditItem {
private: private:
char *value; char *value;
int length; int length;
const char *allowed; char *allowed;
int pos; int pos;
bool insert, newchar, uppercase; bool insert, newchar, uppercase;
void SetHelpKeys(void); void SetHelpKeys(void);

16
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.c 1.32 2002/08/04 10:11:26 kls Exp $ * $Id: osd.c 1.33 2002/08/11 11:43:22 kls Exp $
*/ */
#include "osd.h" #include "osd.h"
@ -279,13 +279,13 @@ cOsdItem::cOsdItem(const char *Text, eOSState State)
cOsdItem::~cOsdItem() cOsdItem::~cOsdItem()
{ {
delete text; free(text);
} }
void cOsdItem::SetText(const char *Text, bool Copy) void cOsdItem::SetText(const char *Text, bool Copy)
{ {
delete text; free(text);
text = Copy ? strdup(Text) : Text; text = Copy ? strdup(Text) : (char *)Text; // text assumes ownership!
} }
void cOsdItem::SetColor(eDvbColor FgColor, eDvbColor BgColor) void cOsdItem::SetColor(eDvbColor FgColor, eDvbColor BgColor)
@ -337,9 +337,9 @@ cOsdMenu::cOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4)
cOsdMenu::~cOsdMenu() cOsdMenu::~cOsdMenu()
{ {
delete title; free(title);
delete subMenu; delete subMenu;
delete status; free(status);
Interface->Clear(); Interface->Clear();
Interface->Close(); Interface->Close();
} }
@ -367,7 +367,7 @@ void cOsdMenu::SetHasHotkeys(void)
void cOsdMenu::SetStatus(const char *s) void cOsdMenu::SetStatus(const char *s)
{ {
delete status; free(status);
status = s ? strdup(s) : NULL; status = s ? strdup(s) : NULL;
if (visible) if (visible)
Interface->Status(status); Interface->Status(status);
@ -375,7 +375,7 @@ void cOsdMenu::SetStatus(const char *s)
void cOsdMenu::SetTitle(const char *Title, bool ShowDate) void cOsdMenu::SetTitle(const char *Title, bool ShowDate)
{ {
delete title; free(title);
if (ShowDate) if (ShowDate)
asprintf(&title, "%s\t%s", Title, DayDateTime(time(NULL))); asprintf(&title, "%s\t%s", Title, DayDateTime(time(NULL)));
else else

6
osd.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.h 1.33 2002/07/13 12:47:06 kls Exp $ * $Id: osd.h 1.34 2002/08/11 11:42:15 kls Exp $
*/ */
#ifndef __OSD_H #ifndef __OSD_H
@ -89,7 +89,7 @@ public:
class cOsdItem : public cListObject { class cOsdItem : public cListObject {
private: private:
const char *text; char *text;
int offset; int offset;
eOSState state; eOSState state;
protected: protected:
@ -128,7 +128,7 @@ private:
int first, current, marked; int first, current, marked;
cOsdMenu *subMenu; cOsdMenu *subMenu;
const char *helpRed, *helpGreen, *helpYellow, *helpBlue; const char *helpRed, *helpGreen, *helpYellow, *helpBlue;
const char *status; char *status;
int digit; int digit;
bool hasHotkeys; bool hasHotkeys;
protected: protected:

View File

@ -4,11 +4,12 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osdbase.c 1.5 2002/07/13 14:42:47 kls Exp $ * $Id: osdbase.c 1.6 2002/08/11 11:47:21 kls Exp $
*/ */
#include "osdbase.h" #include "osdbase.h"
#include <signal.h> #include <signal.h>
#include <stdlib.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/unistd.h> #include <sys/unistd.h>
@ -109,7 +110,7 @@ cBitmap::cBitmap(int Width, int Height, int Bpp, bool ClearWithBackground)
fontType = fontOsd; fontType = fontOsd;
font = NULL; font = NULL;
if (width > 0 && height > 0) { if (width > 0 && height > 0) {
bitmap = new char[width * height]; bitmap = MALLOC(char, width * height);
if (bitmap) { if (bitmap) {
Clean(); Clean();
memset(bitmap, 0x00, width * height); memset(bitmap, 0x00, width * height);
@ -125,7 +126,7 @@ cBitmap::cBitmap(int Width, int Height, int Bpp, bool ClearWithBackground)
cBitmap::~cBitmap() cBitmap::~cBitmap()
{ {
delete font; delete font;
delete bitmap; free(bitmap);
} }
eDvbFont cBitmap::SetFont(eDvbFont Font) eDvbFont cBitmap::SetFont(eDvbFont Font)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: plugin.c 1.6 2002/08/11 10:47:11 kls Exp $ * $Id: plugin.c 1.7 2002/08/11 11:21:00 kls Exp $
*/ */
#include "plugin.h" #include "plugin.h"
@ -102,7 +102,7 @@ void cPlugin::SetConfigDirectory(const char *Dir)
const char *cPlugin::ConfigDirectory(const char *PluginName) const char *cPlugin::ConfigDirectory(const char *PluginName)
{ {
static char *buffer = NULL; static char *buffer = NULL;
delete buffer; free(buffer);
asprintf(&buffer, "%s/plugins%s%s", configDirectory, PluginName ? "/" : "", PluginName ? PluginName : ""); asprintf(&buffer, "%s/plugins%s%s", configDirectory, PluginName ? "/" : "", PluginName ? PluginName : "");
return MakeDirs(buffer, true) ? buffer : NULL; return MakeDirs(buffer, true) ? buffer : NULL;
} }
@ -122,8 +122,8 @@ cDll::~cDll()
delete plugin; delete plugin;
if (handle) if (handle)
dlclose(handle); dlclose(handle);
delete args; free(args);
delete fileName; free(fileName);
} }
static char *SkipQuote(char *s) static char *SkipQuote(char *s)
@ -237,14 +237,14 @@ cPluginManager::cPluginManager(const char *Directory)
cPluginManager::~cPluginManager() cPluginManager::~cPluginManager()
{ {
Shutdown(); Shutdown();
delete directory; free(directory);
if (pluginManager == this) if (pluginManager == this)
pluginManager = NULL; pluginManager = NULL;
} }
void cPluginManager::SetDirectory(const char *Directory) void cPluginManager::SetDirectory(const char *Directory)
{ {
delete directory; free(directory);
directory = Directory ? strdup(Directory) : NULL; directory = Directory ? strdup(Directory) : NULL;
} }
@ -280,8 +280,8 @@ void cPluginManager::AddPlugin(const char *Args)
char *buffer = NULL; char *buffer = NULL;
asprintf(&buffer, "%s/%s%s%s%s", directory, LIBVDR_PREFIX, s, SO_INDICATOR, VDRVERSION); asprintf(&buffer, "%s/%s%s%s%s", directory, LIBVDR_PREFIX, s, SO_INDICATOR, VDRVERSION);
dlls.Add(new cDll(buffer, Args)); dlls.Add(new cDll(buffer, Args));
delete buffer; free(buffer);
delete s; free(s);
} }
bool cPluginManager::LoadPlugins(bool Log) bool cPluginManager::LoadPlugins(bool Log)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.c 1.65 2002/07/27 12:55:14 kls Exp $ * $Id: recording.c 1.66 2002/08/11 11:48:11 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -148,7 +148,7 @@ void AssertFreeDiskSpace(int Priority)
cResumeFile::cResumeFile(const char *FileName) cResumeFile::cResumeFile(const char *FileName)
{ {
fileName = new char[strlen(FileName) + strlen(RESUMEFILESUFFIX) + 1]; fileName = MALLOC(char, strlen(FileName) + strlen(RESUMEFILESUFFIX) + 1);
if (fileName) { if (fileName) {
strcpy(fileName, FileName); strcpy(fileName, FileName);
strcat(fileName, RESUMEFILESUFFIX); strcat(fileName, RESUMEFILESUFFIX);
@ -159,7 +159,7 @@ cResumeFile::cResumeFile(const char *FileName)
cResumeFile::~cResumeFile() cResumeFile::~cResumeFile()
{ {
delete fileName; free(fileName);
} }
int cResumeFile::Read(void) int cResumeFile::Read(void)
@ -375,7 +375,7 @@ cRecording::cRecording(const char *FileName)
struct stat buf; struct stat buf;
if (fstat(f, &buf) == 0) { if (fstat(f, &buf) == 0) {
int size = buf.st_size; int size = buf.st_size;
summary = new char[size + 1]; // +1 for terminating 0 summary = MALLOC(char, size + 1); // +1 for terminating 0
if (summary) { if (summary) {
int rbytes = safe_read(f, summary, size); int rbytes = safe_read(f, summary, size);
if (rbytes >= 0) { if (rbytes >= 0) {
@ -385,7 +385,7 @@ cRecording::cRecording(const char *FileName)
} }
else { else {
LOG_ERROR_STR(SummaryFileName); LOG_ERROR_STR(SummaryFileName);
delete summary; free(summary);
summary = NULL; summary = NULL;
} }
@ -399,17 +399,17 @@ cRecording::cRecording(const char *FileName)
} }
else if (errno != ENOENT) else if (errno != ENOENT)
LOG_ERROR_STR(SummaryFileName); LOG_ERROR_STR(SummaryFileName);
delete SummaryFileName; free(SummaryFileName);
} }
} }
cRecording::~cRecording() cRecording::~cRecording()
{ {
delete titleBuffer; free(titleBuffer);
delete sortBuffer; free(sortBuffer);
delete fileName; free(fileName);
delete name; free(name);
delete summary; free(summary);
} }
char *cRecording::StripEpisodeName(char *s) char *cRecording::StripEpisodeName(char *s)
@ -437,9 +437,9 @@ char *cRecording::SortName(void)
if (!sortBuffer) { if (!sortBuffer) {
char *s = StripEpisodeName(strdup(FileName() + strlen(VideoDirectory) + 1)); char *s = StripEpisodeName(strdup(FileName() + strlen(VideoDirectory) + 1));
int l = strxfrm(NULL, s, 0); int l = strxfrm(NULL, s, 0);
sortBuffer = new char[l]; sortBuffer = MALLOC(char, l);
strxfrm(sortBuffer, s, l); strxfrm(sortBuffer, s, l);
delete s; free(s);
} }
return sortBuffer; return sortBuffer;
} }
@ -474,7 +474,7 @@ const char *cRecording::FileName(void)
const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level)
{ {
char New = NewIndicator && IsNew() ? '*' : ' '; char New = NewIndicator && IsNew() ? '*' : ' ';
delete titleBuffer; free(titleBuffer);
titleBuffer = NULL; titleBuffer = NULL;
if (Level < 0 || Level == HierarchyLevels()) { if (Level < 0 || Level == HierarchyLevels()) {
struct tm tm_r; struct tm tm_r;
@ -524,7 +524,7 @@ const char *cRecording::PrefixFileName(char Prefix)
{ {
const char *p = PrefixVideoFileName(FileName(), Prefix); const char *p = PrefixVideoFileName(FileName(), Prefix);
if (p) { if (p) {
delete fileName; free(fileName);
fileName = strdup(p); fileName = strdup(p);
return fileName; return fileName;
} }
@ -555,7 +555,7 @@ bool cRecording::WriteSummary(void)
} }
else else
LOG_ERROR_STR(SummaryFileName); LOG_ERROR_STR(SummaryFileName);
delete SummaryFileName; free(SummaryFileName);
} }
return true; return true;
} }
@ -575,7 +575,7 @@ bool cRecording::Delete(void)
isyslog("deleting recording %s", FileName()); isyslog("deleting recording %s", FileName());
result = RenameVideoFile(FileName(), NewName); result = RenameVideoFile(FileName(), NewName);
} }
delete NewName; free(NewName);
return result; return result;
} }
@ -614,7 +614,7 @@ bool cRecordings::Load(bool Deleted)
} }
else else
Interface->Error("Error while opening pipe!"); Interface->Error("Error while opening pipe!");
delete cmd; free(cmd);
return result; return result;
} }
@ -639,19 +639,19 @@ cMark::cMark(int Position, const char *Comment)
cMark::~cMark() cMark::~cMark()
{ {
delete comment; free(comment);
} }
const char *cMark::ToText(void) const char *cMark::ToText(void)
{ {
delete buffer; free(buffer);
asprintf(&buffer, "%s%s%s\n", IndexToHMSF(position, true), comment ? " " : "", comment ? comment : ""); asprintf(&buffer, "%s%s%s\n", IndexToHMSF(position, true), comment ? " " : "", comment ? comment : "");
return buffer; return buffer;
} }
bool cMark::Parse(const char *s) bool cMark::Parse(const char *s)
{ {
delete comment; free(comment);
comment = NULL; comment = NULL;
position = HMSFToIndex(s); position = HMSFToIndex(s);
const char *p = strchr(s, ' '); const char *p = strchr(s, ' ');
@ -742,7 +742,7 @@ void cRecordingUserCommand::InvokeCommand(const char *State, const char *Recordi
asprintf(&cmd, "%s %s \"%s\"", command, State, strescape(RecordingFileName, "\"$")); asprintf(&cmd, "%s %s \"%s\"", command, State, strescape(RecordingFileName, "\"$"));
isyslog("executing '%s'", cmd); isyslog("executing '%s'", cmd);
SystemExec(cmd); SystemExec(cmd);
delete cmd; free(cmd);
} }
} }
@ -782,13 +782,13 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
last = (buf.st_size + delta) / sizeof(tIndex) - 1; last = (buf.st_size + delta) / sizeof(tIndex) - 1;
if (!Record && last >= 0) { if (!Record && last >= 0) {
size = last + 1; size = last + 1;
index = new tIndex[size]; index = MALLOC(tIndex, size);
if (index) { if (index) {
f = open(fileName, O_RDONLY); f = open(fileName, O_RDONLY);
if (f >= 0) { if (f >= 0) {
if ((int)safe_read(f, index, buf.st_size) != buf.st_size) { if ((int)safe_read(f, index, buf.st_size) != buf.st_size) {
esyslog("ERROR: can't read from file '%s'", fileName); esyslog("ERROR: can't read from file '%s'", fileName);
delete index; free(index);
index = NULL; index = NULL;
close(f); close(f);
f = -1; f = -1;
@ -828,8 +828,8 @@ cIndexFile::~cIndexFile()
{ {
if (f >= 0) if (f >= 0)
close(f); close(f);
delete fileName; free(fileName);
delete index; free(index);
} }
bool cIndexFile::CatchUp(int Index) bool cIndexFile::CatchUp(int Index)
@ -852,7 +852,7 @@ bool cIndexFile::CatchUp(int Index)
if (lseek(f, offset, SEEK_SET) == offset) { if (lseek(f, offset, SEEK_SET) == offset) {
if (safe_read(f, &index[last + 1], delta) != delta) { if (safe_read(f, &index[last + 1], delta) != delta) {
esyslog("ERROR: can't read from index"); esyslog("ERROR: can't read from index");
delete index; free(index);
index = NULL; index = NULL;
close(f); close(f);
f = -1; f = -1;
@ -999,7 +999,7 @@ cFileName::cFileName(const char *FileName, bool Record, bool Blocking)
cFileName::~cFileName() cFileName::~cFileName()
{ {
Close(); Close();
delete fileName; free(fileName);
} }
int cFileName::Open(void) int cFileName::Open(void)

View File

@ -8,7 +8,7 @@
* the Linux DVB driver's 'tuxplayer' example and were rewritten to suit * the Linux DVB driver's 'tuxplayer' example and were rewritten to suit
* VDR's needs. * VDR's needs.
* *
* $Id: remux.c 1.10 2002/08/11 10:53:10 kls Exp $ * $Id: remux.c 1.11 2002/08/11 11:48:34 kls Exp $
*/ */
/* The calling interface of the 'cRemux::Process()' function is defined /* The calling interface of the 'cRemux::Process()' function is defined
@ -66,6 +66,7 @@
*/ */
#include "remux.h" #include "remux.h"
#include <stdlib.h>
#include "thread.h" #include "thread.h"
#include "tools.h" #include "tools.h"
@ -153,7 +154,7 @@ cTS2PES::cTS2PES(uint8_t *ResultBuffer, int *ResultCount, int Size, uint8_t Audi
size = Size; size = Size;
audioCid = AudioCid; audioCid = AudioCid;
if (!(buf = new uint8_t[size])) if (!(buf = MALLOC(uint8_t, size)))
esyslog("Not enough memory for ts_transform"); esyslog("Not enough memory for ts_transform");
reset_ipack(); reset_ipack();
@ -161,7 +162,7 @@ cTS2PES::cTS2PES(uint8_t *ResultBuffer, int *ResultCount, int Size, uint8_t Audi
cTS2PES::~cTS2PES() cTS2PES::~cTS2PES()
{ {
delete buf; free(buf);
} }
void cTS2PES::Clear(void) void cTS2PES::Clear(void)

11
svdrp.c
View File

@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured * and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection. * graphical interface that sits on top of an SVDRP connection.
* *
* $Id: svdrp.c 1.38 2002/06/10 16:30:00 kls Exp $ * $Id: svdrp.c 1.39 2002/08/11 12:01:28 kls Exp $
*/ */
#include "svdrp.h" #include "svdrp.h"
@ -37,6 +37,7 @@ cSocket::cSocket(int Port, int Queue)
{ {
port = Port; port = Port;
sock = -1; sock = -1;
queue = Queue;
} }
cSocket::~cSocket() cSocket::~cSocket()
@ -320,7 +321,7 @@ cSVDRP::cSVDRP(int Port)
cSVDRP::~cSVDRP() cSVDRP::~cSVDRP()
{ {
Close(); Close();
delete message; free(message);
} }
void cSVDRP::Close(bool Timeout) void cSVDRP::Close(bool Timeout)
@ -370,7 +371,7 @@ void cSVDRP::Reply(int Code, const char *fmt, ...)
} }
s = n ? n + 1 : NULL; s = n ? n + 1 : NULL;
} }
delete buffer; free(buffer);
va_end(ap); va_end(ap);
} }
else { else {
@ -685,7 +686,7 @@ void cSVDRP::CmdLSTR(const char *Option)
if (recording->Summary()) { if (recording->Summary()) {
char *summary = strdup(recording->Summary()); char *summary = strdup(recording->Summary());
Reply(250, "%s", strreplace(summary,'\n','|')); Reply(250, "%s", strreplace(summary,'\n','|'));
delete summary; free(summary);
} }
else else
Reply(550, "No summary availabe"); Reply(550, "No summary availabe");
@ -736,7 +737,7 @@ void cSVDRP::CmdLSTT(const char *Option)
void cSVDRP::CmdMESG(const char *Option) void cSVDRP::CmdMESG(const char *Option)
{ {
if (*Option) { if (*Option) {
delete message; free(message);
message = strdup(Option); message = strdup(Option);
isyslog("SVDRP message: '%s'", message); isyslog("SVDRP message: '%s'", message);
Reply(250, "Message stored"); Reply(250, "Message stored");

28
tools.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "tools.h"
@ -80,7 +80,7 @@ char *strcpyrealloc(char *dest, const char *src)
esyslog("ERROR: out of memory"); esyslog("ERROR: out of memory");
} }
else { else {
delete dest; free(dest);
dest = NULL; dest = NULL;
} }
return dest; return dest;
@ -239,7 +239,7 @@ bool isnumber(const char *s)
const char *AddDirectory(const char *DirName, const char *FileName) const char *AddDirectory(const char *DirName, const char *FileName)
{ {
static char *buf = NULL; static char *buf = NULL;
delete buf; free(buf);
asprintf(&buf, "%s/%s", DirName && *DirName ? DirName : ".", FileName); asprintf(&buf, "%s/%s", DirName && *DirName ? DirName : ".", FileName);
return buf; return buf;
} }
@ -303,7 +303,7 @@ bool MakeDirs(const char *FileName, bool IsDirectory)
else else
break; break;
} }
delete s; free(s);
return result; return result;
} }
@ -321,7 +321,7 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
asprintf(&buffer, "%s/%s", FileName, e->d_name); asprintf(&buffer, "%s/%s", FileName, e->d_name);
if (FollowSymlinks) { if (FollowSymlinks) {
int size = strlen(buffer) * 2; // should be large enough 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); int n = readlink(buffer, l, size);
if (n < 0) { if (n < 0) {
if (errno != EINVAL) if (errno != EINVAL)
@ -335,12 +335,12 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
} }
else else
esyslog("ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size); esyslog("ERROR: symlink name length (%d) exceeded anticipated buffer size (%d)", n, size);
delete l; free(l);
} }
dsyslog("removing %s", buffer); dsyslog("removing %s", buffer);
if (remove(buffer) < 0) if (remove(buffer) < 0)
LOG_ERROR_STR(buffer); LOG_ERROR_STR(buffer);
delete buffer; free(buffer);
} }
} }
closedir(d); closedir(d);
@ -384,10 +384,10 @@ bool RemoveEmptyDirectories(const char *DirName, bool RemoveThis)
} }
else { else {
LOG_ERROR_STR(buffer); LOG_ERROR_STR(buffer);
delete buffer; free(buffer);
return false; return false;
} }
delete buffer; free(buffer);
} }
} }
closedir(d); closedir(d);
@ -429,7 +429,7 @@ bool SpinUpDisk(const char *FileName)
{ {
static char *buf = NULL; static char *buf = NULL;
for (int n = 0; n < 10; n++) { for (int n = 0; n < 10; n++) {
delete buf; free(buf);
if (DirectoryOk(FileName)) if (DirectoryOk(FileName))
asprintf(&buf, "%s/vdr-%06d", *FileName ? FileName : ".", n); asprintf(&buf, "%s/vdr-%06d", *FileName ? FileName : ".", n);
else else
@ -594,7 +594,7 @@ cSafeFile::cSafeFile(const char *FileName)
{ {
f = NULL; f = NULL;
fileName = ReadLink(FileName); fileName = ReadLink(FileName);
tempName = fileName ? new char[strlen(fileName) + 5] : NULL; tempName = fileName ? MALLOC(char, strlen(fileName) + 5) : NULL;
if (tempName) if (tempName)
strcat(strcpy(tempName, fileName), ".$$$"); strcat(strcpy(tempName, fileName), ".$$$");
} }
@ -604,8 +604,8 @@ cSafeFile::~cSafeFile()
if (f) if (f)
fclose(f); fclose(f);
unlink(tempName); unlink(tempName);
delete fileName; free(fileName);
delete tempName; free(tempName);
} }
bool cSafeFile::Open(void) bool cSafeFile::Open(void)
@ -657,7 +657,7 @@ cLockFile::cLockFile(const char *Directory)
cLockFile::~cLockFile() cLockFile::~cLockFile()
{ {
Unlock(); Unlock();
delete fileName; free(fileName);
} }
bool cLockFile::Lock(int WaitSeconds) bool cLockFile::Lock(int WaitSeconds)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.h 1.47 2002/06/10 16:30:00 kls Exp $ * $Id: tools.h 1.48 2002/08/11 11:34:26 kls Exp $
*/ */
#ifndef __TOOLS_H #ifndef __TOOLS_H
@ -36,6 +36,8 @@ extern int SysLogLevel;
#define MAXPARSEBUFFER KILOBYTE(10) #define MAXPARSEBUFFER KILOBYTE(10)
#define MALLOC(type, size) (type *)malloc(sizeof(type) * (size))
#define DELETENULL(p) (delete (p), p = NULL) #define DELETENULL(p) (delete (p), p = NULL)
#define CHECK(s) { if ((s) < 0) LOG_ERROR; } // used for 'ioctl()' calls #define CHECK(s) { if ((s) < 0) LOG_ERROR; } // used for 'ioctl()' calls

6
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * The project's page is at http://www.cadsoft.de/people/kls/vdr
* *
* $Id: vdr.c 1.118 2002/08/04 09:56:30 kls Exp $ * $Id: vdr.c 1.119 2002/08/11 11:32:15 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -585,7 +585,7 @@ int main(int argc, char *argv[])
asprintf(&buf, tr("Recording in %d minutes, shut down anyway?"), Delta / 60); asprintf(&buf, tr("Recording in %d minutes, shut down anyway?"), Delta / 60);
if (Interface->Confirm(buf)) if (Interface->Confirm(buf))
ForceShutdown = true; ForceShutdown = true;
delete buf; free(buf);
} }
if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) { if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) {
ForceShutdown = false; ForceShutdown = false;
@ -600,7 +600,7 @@ int main(int argc, char *argv[])
asprintf(&cmd, "%s %ld %ld %d \"%s\" %d", Shutdown, Next, Delta, Channel, strescape(File, "\"$"), UserShutdown); asprintf(&cmd, "%s %ld %ld %d \"%s\" %d", Shutdown, Next, Delta, Channel, strescape(File, "\"$"), UserShutdown);
isyslog("executing '%s'", cmd); isyslog("executing '%s'", cmd);
SystemExec(cmd); SystemExec(cmd);
delete cmd; free(cmd);
} }
else if (WatchdogTimeout > 0) { else if (WatchdogTimeout > 0) {
alarm(WatchdogTimeout); alarm(WatchdogTimeout);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: videodir.c 1.8 2002/05/13 16:32:52 kls Exp $ * $Id: videodir.c 1.9 2002/08/11 13:31:02 kls Exp $
*/ */
#include "videodir.h" #include "videodir.h"
@ -48,9 +48,9 @@ cVideoDirectory::cVideoDirectory(void)
cVideoDirectory::~cVideoDirectory() cVideoDirectory::~cVideoDirectory()
{ {
delete name; free(name);
delete stored; free(stored);
delete adjusted; free(adjusted);
} }
int cVideoDirectory::FreeMB(int *UsedMB) int cVideoDirectory::FreeMB(int *UsedMB)
@ -87,7 +87,7 @@ bool cVideoDirectory::Next(void)
void cVideoDirectory::Store(void) void cVideoDirectory::Store(void)
{ {
if (name) { if (name) {
delete stored; free(stored);
stored = strdup(name); stored = strdup(name);
} }
} }
@ -95,7 +95,7 @@ void cVideoDirectory::Store(void)
const char *cVideoDirectory::Adjust(const char *FileName) const char *cVideoDirectory::Adjust(const char *FileName)
{ {
if (stored) { if (stored) {
delete adjusted; free(adjusted);
adjusted = strdup(FileName); adjusted = strdup(FileName);
return strncpy(adjusted, stored, length); return strncpy(adjusted, stored, length);
} }
@ -139,7 +139,7 @@ int OpenVideoFile(const char *FileName, int Flags)
} }
int Result = open(ActualFileName, Flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); int Result = open(ActualFileName, Flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (ActualFileName != FileName) if (ActualFileName != FileName)
delete ActualFileName; free((char *)ActualFileName);
return Result; return Result;
} }