Fixed few memory leeks.

This commit is contained in:
Ianos Gnatiuc 2007-01-08 12:09:42 +00:00
parent 3750658bf2
commit 18d26cabfc
23 changed files with 111 additions and 55 deletions

View File

@ -52,6 +52,7 @@ Global
{C23888DA-7024-4A38-A8C5-CE4BEFA4629A}.Release|x64.ActiveCfg = Release|x64
{C23888DA-7024-4A38-A8C5-CE4BEFA4629A}.Release|x64.Build.0 = Release|x64
{B80E3728-98E5-4A9A-B883-9C064F1FFFA7}.Debug|Win32.ActiveCfg = Debug|Win32
{B80E3728-98E5-4A9A-B883-9C064F1FFFA7}.Debug|Win32.Build.0 = Debug|Win32
{B80E3728-98E5-4A9A-B883-9C064F1FFFA7}.Debug|x64.ActiveCfg = Debug|x64
{B80E3728-98E5-4A9A-B883-9C064F1FFFA7}.Debug|x64.Build.0 = Debug|x64
{B80E3728-98E5-4A9A-B883-9C064F1FFFA7}.Release|Win32.ActiveCfg = Release|Win32
@ -59,6 +60,7 @@ Global
{B80E3728-98E5-4A9A-B883-9C064F1FFFA7}.Release|x64.ActiveCfg = Release|x64
{B80E3728-98E5-4A9A-B883-9C064F1FFFA7}.Release|x64.Build.0 = Release|x64
{951D76D2-FA57-4C95-8F65-A6C19C122AA5}.Debug|Win32.ActiveCfg = Debug|Win32
{951D76D2-FA57-4C95-8F65-A6C19C122AA5}.Debug|Win32.Build.0 = Debug|Win32
{951D76D2-FA57-4C95-8F65-A6C19C122AA5}.Debug|x64.ActiveCfg = Debug|x64
{951D76D2-FA57-4C95-8F65-A6C19C122AA5}.Debug|x64.Build.0 = Debug|x64
{951D76D2-FA57-4C95-8F65-A6C19C122AA5}.Release|Win32.ActiveCfg = Release|Win32

View File

@ -141,6 +141,10 @@ Area* AreaList::NewArea(const char *basetype) {
return new Area(ap);
}
Area* AreaList::NewArea(const std::string &basetype)
{
return NewArea(basetype.c_str());
}
// ------------------------------------------------------------------
// Write lastreads for the next session
@ -310,11 +314,11 @@ void AreaList::WriteAreaDef(const char* file)
else if((*aa)->islocal())
strcpy(type, "Local");
#ifndef GMB_NOXBBS
if(streql((*aa)->basetype(), "ADEPTXBBS"))
if ((*aa)->basetype() == "ADEPTXBBS")
strcpy(msgbase, "XBBS");
else
#endif
strxcpy(msgbase, (*aa)->basetype(), sizeof(msgbase));
strxcpy(msgbase, (*aa)->basetype().c_str(), sizeof(msgbase));
if (strchr((*aa)->echoid(), ' '))
gsprintf(PRINTF_DECLARE_BUFFER(echoid), "\"%s\"", (*aa)->echoid());
else
@ -386,11 +390,13 @@ void AreaList::SetAreaDesc(char* echoid, char* desc) {
// ------------------------------------------------------------------
#ifndef GMB_NOPCB
void PcbAdjustArea(uint rec, const char* msgfile) {
for(uint n=0; n<AL.size(); n++) {
void PcbAdjustArea(uint rec, const char* msgfile)
{
for (uint n=0; n<AL.size(); n++)
{
Area* a = AL[n];
if(streql(a->basetype(), "PCBOARD")) {
if (a->basetype() == "PCBOARD")
{
if((a->board() == rec) and (*a->path() == NUL)) {
a->set_path(msgfile);
break;

View File

@ -166,7 +166,8 @@ void AreaList::AddNewArea(AreaCfg* aa)
*desc = NUL;
// Make sure the path field is 100% correct for the msgbase
if(streql(aa->basetype, "FTS1") or streql(aa->basetype, "OPUS")) {
if ((aa->basetype == "FTS1") || (aa->basetype == "OPUS"))
{
if(*aa->path == NUL)
return;
MapPath(aa->path);
@ -174,7 +175,7 @@ void AreaList::AddNewArea(AreaCfg* aa)
strschg_environ(aa->path);
}
#ifndef GMB_NOHUDS
else if (streql(aa->basetype, "HUDSON"))
else if (aa->basetype == "HUDSON")
{
if ((aa->board < 1) or (aa->board > 200)) // Ignore areas with invalid numbers
return;
@ -182,7 +183,7 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
#endif
#ifndef GMB_NOGOLD
else if (streql(aa->basetype, "GOLDBASE"))
else if (aa->basetype == "GOLDBASE")
{
if ((aa->board < 1) or (aa->board > 500)) // Ignore areas with invalid numbers
return;
@ -190,7 +191,7 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
#endif
#ifndef GMB_NOEZY
else if (streql(aa->basetype, "EZYCOM"))
else if (aa->basetype == "EZYCOM")
{
// Ignore areas with invalid numbers
if ((aa->board < 1) or (aa->board > 1536))
@ -199,7 +200,8 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
#endif
#ifndef GMB_NOWCAT
else if(streql(aa->basetype, "WILDCAT")) {
else if (aa->basetype == "WILDCAT")
{
if(*aa->path == NUL)
return;
MapPath(aa->path);
@ -208,7 +210,8 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
#endif
#ifndef GMB_NOXBBS
else if(streql(aa->basetype, "ADEPTXBBS")) {
else if (aa->basetype == "ADEPTXBBS")
{
if(*aa->path == NUL)
return;
MapPath(aa->path);
@ -217,7 +220,8 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
#endif
#ifndef GMB_NOSQSH
else if(streql(aa->basetype, "SQUISH")) {
else if (aa->basetype == "SQUISH")
{
if(*aa->path == NUL)
return;
MapPath(aa->path);
@ -226,7 +230,8 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
#endif
#ifndef GMB_NOJAM
else if(streql(aa->basetype, "JAM")) {
else if (aa->basetype == "JAM")
{
if(*aa->path == NUL)
return;
MapPath(aa->path);
@ -235,14 +240,16 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
#endif
#ifndef GMB_NOPCB
else if(streql(aa->basetype, "PCBOARD")) {
else if (aa->basetype == "PCBOARD")
{
MapPath(aa->path);
StripBackslash(aa->path);
strschg_environ(aa->path);
}
#endif
#ifndef GMB_NOSMB
else if(streql(aa->basetype, "SMB")) {
else if (aa->basetype == "SMB")
{
if(*aa->path == NUL)
return;
MapPath(aa->path);
@ -250,7 +257,8 @@ void AreaList::AddNewArea(AreaCfg* aa)
strschg_environ(aa->path);
}
#endif
else if(streql(aa->basetype, "SEPARATOR")) {
else if (aa->basetype == "SEPARATOR")
{
}
else {
return;
@ -302,13 +310,16 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
break;
}
else if(not (*ap)->isseparator()) {
else if(not (*ap)->isseparator())
{
bool eq_path = strieql(aa->path, (*ap)->path());
bool eq_board = (aa->board == (*ap)->board());
bool eq_msgbase = streql(aa->basetype, (*ap)->basetype());
bool eq_isfido = ((streql(aa->basetype, "OPUS") or streql(aa->basetype, "FTS1"))
and (streql((*ap)->basetype(), "OPUS") or streql((*ap)->basetype(), "FTS1")));
if(eq_path and eq_board and (eq_msgbase or eq_isfido)) {
bool eq_msgbase = (aa->basetype == (*ap)->basetype());
bool eq_isfido = (((aa->basetype == "OPUS") || (aa->basetype == "FTS1")) &&
(((*ap)->basetype() == "OPUS") || ((*ap)->basetype() == "FTS1")));
if (eq_path and eq_board and (eq_msgbase or eq_isfido))
{
// We had it already, so override with the new data
newarea = false;
if(strblank((*ap)->desc()))

View File

@ -289,7 +289,7 @@ extern "C" int AreaListCmp(const Area** __a, const Area** __b) {
else if(B->isseparator()) {
return sepfirst?1:-1;
}
else if((cmp = strcmp(A->basetype(), B->basetype())) != 0)
else if ((cmp = strcmp(A->basetype().c_str(), B->basetype().c_str())) != 0)
return cmp;
break;
case 'Y':

View File

@ -601,7 +601,11 @@ void CmfMsgs(GMsg* msg, bool torecycle)
bool need_fmpt = true;
bool need_topt = true;
if(not need_netmail_kludges and streql(AAorig->basetype(), "SQUISH") and strcmp(AAdest->basetype(), "SQUISH") and AAdest->isnet() and AAorig->isnet()) {
if (not need_netmail_kludges &&
(AAorig->basetype() == "SQUISH") &&
(AAdest->basetype() == "SQUISH") &&
AAdest->isnet() && AAorig->isnet())
{
if(msg->orig.point and not strstr(msg->txt, "\001FMPT"))
need_netmail_kludges = true;
else

View File

@ -96,9 +96,11 @@ char* MakeTearline(GMsg* msg, char* buf) {
void MakeFlags(GMsg* msg, Line** line, char* buf) {
// The FrontDoor FLAGS netmail kludge
if(CFG->switches.get(useflags)) {
if (CFG->switches.get(useflags))
{
sprintf(buf, "\001FLAGS ");
if(streql(AA->basetype(), "HUDSON")) {
if (AA->basetype() == "HUDSON")
{
if(msg->attr.hld())
strcat(buf, "HLD ");
if(msg->attr.frq())
@ -360,7 +362,9 @@ void DoKludges(int mode, GMsg* msg, int kludges) {
msg->orig.make_string(buf2, msg->odom);
gsprintf(PRINTF_DECLARE_BUFFER(msg->msgids), "%s %08x", buf2, getMsgId());
}
if(CFG->switches.get(usemsgid) and strcmp(AA->basetype(), "PCBOARD")) {
if (CFG->switches.get(usemsgid) && (AA->basetype() == "PCBOARD"))
{
sprintf(buf, "\001MSGID: %s", msg->msgids);
line = AddKludge(line, buf);
line->kludge = GKLUD_MSGID;

View File

@ -377,14 +377,15 @@ char* GetCurrQuotebuf(char* quotebuf) {
strcpy(quotebuf, AA->Quotebuffile());
MakePathname(quotebuf, CFG->goldpath, quotebuf);
}
else {
if(streql(AA->basetype(), "EZYCOM"))
else
{
if (AA->basetype() == "EZYCOM")
sprintf(quotebuf, "%sgld%05u.qbf", CFG->ezycom.msgbasepath, AA->board());
else if(streql(AA->basetype(), "FTS1") or streql(AA->basetype(), "OPUS"))
else if ((AA->basetype() == "FTS1") || (AA->basetype() == "OPUS"))
sprintf(quotebuf, "%s%s", AA->path(), "golded.qbf");
else if(streql(AA->basetype(), "GOLDBASE"))
else if (AA->basetype() == "GOLDBASE")
sprintf(quotebuf, "%sgoldg%03u.qbf", CFG->goldbasepath, AA->board());
else if(streql(AA->basetype(), "HUDSON"))
else if (AA->basetype() == "HUDSON")
sprintf(quotebuf, "%sgoldh%03u.qbf", CFG->hudsonpath, AA->board());
else
sprintf(quotebuf, "%s%s", AA->path(), ".qbf");

View File

@ -507,6 +507,7 @@ BOOL WINAPI GoldedCtrlHandler(DWORD dwCtrlType) {
void Uninitialize()
{
delete WideUsername;
LookupNodeClear();
}

View File

@ -2069,7 +2069,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool getvalue, bool header_recode) {
line = AddLine(line, "");
ptr = msg->txt;
uint _size = strlen(msg->txt);
if(streql(AA->basetype(), "OPUS") or streql(AA->basetype(), "FTS1"))
if ((AA->basetype() == "OPUS") || (AA->basetype() == "FTS1"))
idxadjust = 190;
for (idx=0; idx < _size; ptr+=16,idx+=16)
{

View File

@ -494,7 +494,7 @@ void TokenXlat(int mode, std::string &input, GMsg* msg, GMsg* oldmsg, int __orig
if (strnieql(it2str(input, dst), "@area", 5))
{
if (tokenxchg(input, dst, "@areatype", AA->basetype()))
if (tokenxchg(input, dst, "@areatype", AA->basetype().c_str()))
continue;
char areapath[GMAXPATH];
@ -958,7 +958,7 @@ void GMsg::LinesToText() {
strxcpy(re, _buf, sizeof(ISub));
}
bool _lfterm = EDIT->CrLfTerm() and strcmp(AA->basetype(), "PCBOARD");
bool _lfterm = EDIT->CrLfTerm() and (AA->basetype() == "PCBOARD");
bool _hardterm = AA->Edithardterm() or AA->requirehardterm();
bool _softterm = AA->requiresoftterm();

View File

@ -1095,10 +1095,15 @@ struct location_item
bool operator==(Addr &other) { return addr.equals(other); }
};
std::vector<location_item> g_LocationCash;
void LookupNodeClear()
{
g_LocationCash.clear();
}
void LookupNodeLocation(GMsg* msg, std::string &location, int what)
{
static std::vector<location_item> cash;
Subj statuslinebak;
strcpy(statuslinebak, information);
@ -1119,8 +1124,8 @@ void LookupNodeLocation(GMsg* msg, std::string &location, int what)
if (addr.zone == 0)
addr.zone = AA->Aka().addr.zone;
std::vector<location_item>::iterator it = cash.begin();
std::vector<location_item>::iterator end = cash.end();
std::vector<location_item>::iterator it = g_LocationCash.begin();
std::vector<location_item>::iterator end = g_LocationCash.end();
while ((it != end) && (*it < addr)) it++;
@ -1165,7 +1170,7 @@ void LookupNodeLocation(GMsg* msg, std::string &location, int what)
}
item.loc = location = city;
cash.insert(it, item);
g_LocationCash.insert(it, item);
}
update_statusline(statuslinebak);

View File

@ -1001,7 +1001,7 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
{
if (CFG->replylink != REPLYLINK_NONE)
{
if ((CFG->replylink == REPLYLINK_DIRECT) or streql(AA->basetype(), "JAM"))
if ((CFG->replylink == REPLYLINK_DIRECT) or (AA->basetype() == "JAM"))
reply_msgno = omsg->msgno;
else if (CFG->replylink == REPLYLINK_CHAIN)
GetLastLink(omsg, reply_msgno);
@ -1158,7 +1158,7 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
uint32_t replynext;
bool ok2save = false;
if (streql(AA->basetype(), "SQUISH"))
if (AA->basetype() == "SQUISH")
{
if (reply->link.first())
{
@ -1177,7 +1177,8 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
ok2save = true;
}
}
else if(streql(AA->basetype(), "JAM")) {
else if (AA->basetype() == "JAM")
{
if(reply->link.first()) {
replynext = reply->link.first();
do {

View File

@ -304,6 +304,7 @@ const char *lookup_nodelist(ftn_addr* addr);
void LookupNodeLocation(GMsg* msg, std::string &location, int what);
void LookupNode(GMsg* msg, const char* name, int what);
void LookupNodeClear();
void CheckNodelists();
@ -481,6 +482,7 @@ char* strtmp(const char* str);
vattr quotecolor(const char* line);
void doinvalidate(char* text, const char* find, const char* replace, bool is_tearline = false);
bool find(const std::vector<const char *> &vec, const char *str);
bool find(const std::vector<std::string> &vec, const std::string &str);
vattr GetColorName(const char *name, Addr &addr, vattr color);

View File

@ -744,3 +744,17 @@ bool find(const std::vector<const char *> &vec, const char *str) {
return false;
}
bool find(const std::vector<std::string> &vec, const std::string &str)
{
std::vector<std::string>::const_iterator it = vec.begin();
std::vector<std::string>::const_iterator end = vec.end();
for (; it != end; it++)
{
if ((*it) == str)
return true;
}
return false;
}

View File

@ -300,7 +300,8 @@ void Area::SaveMsg(int mode, GMsg* msg) {
echopost++;
}
if(streql(basetype(), "JAM") and (isecho() or isnet())) {
if ((basetype() == "JAM") && (isecho() or isnet()))
{
Path p;
sprintf(file, "%s%smail.jam", CFG->jampath, isecho() ? "echo" : "net");

View File

@ -192,7 +192,7 @@ public:
char sortspec[20];
// Active msgbases (bitmap of MT_* contants)
std::vector<const char *> basetypes;
std::vector<std::string> basetypes;
// Additional items to the area scan menu
GAreaListScan ListScan;
@ -216,6 +216,7 @@ public:
// Return pointer to a new'd area of the specified format
Area* NewArea(const char *basetype);
Area* NewArea(const std::string &basetype);
// Sort areas
void Sort(const char* specs=NULL, int first=0, int last=-1);
@ -489,7 +490,7 @@ public:
int areaid() const { return area->areaid(); }
int groupid() const { return area->groupid(); }
uint type() const { return area->type(); }
const char *basetype() const { return area->basetype(); }
const std::string &basetype() const { return area->basetype(); }
uint board() const { return area->board(); }
const ftn_addr& aka() const { return area->aka(); }
int originno() const { return area->originno(); }
@ -515,6 +516,7 @@ public:
void set_groupid(int g) { area->set_groupid(g); }
void set_type(uint t) { area->set_type(t); }
void set_basetype(const char *m) { area->set_basetype(m); }
void set_basetype(const std::string &m) { area->set_basetype(m); }
void set_board(uint b) { area->set_board(b); }
void set_aka(ftn_addr& a) { area->set_aka(a); }
void set_originno(int o) { area->set_originno(o); }

View File

@ -65,7 +65,7 @@ public:
int originno; // Origin number
uint board; // Board number (Hudson/Goldbase/Ezycom/PCBoard fmts)
uint type; // Type of msgarea (GMB_xxx)
const char *basetype; // Type of msgbase
std::string basetype; // Type of msgbase
ftn_addr aka; // The AKA to use in the area
ftn_attr attr; // Default attributes
byte scan : 1; // TRUE if listed with AREASCAN
@ -77,7 +77,7 @@ public:
int setorigin(std::string& origin);
bool isseparator() const { return streql(basetype, "SEPARATOR"); }
bool isseparator() const { return (basetype == "SEPARATOR"); }
bool isnet() const { return !!(type & GMB_NET); }
bool isecho() const { return !!(type & GMB_ECHO); }

View File

@ -358,19 +358,19 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
switch(aa.type) {
case GMB_NET:
aa.attr = attribsnet;
if(*aa.basetype == '\0')
if (aa.basetype.empty())
aa.basetype = fidomsgtype;
AddNewArea(aa);
break;
case GMB_ECHO:
aa.attr = attribsecho;
if(*aa.basetype == '\0')
if (aa.basetype.empty())
aa.basetype = fidomsgtype;
AddNewArea(aa);
break;
case GMB_LOCAL:
aa.attr = attribslocal;
if(*aa.basetype == '\0')
if (aa.basetype.empty())
aa.basetype = fidomsgtype;
AddNewArea(aa);
break;

View File

@ -83,7 +83,7 @@ void gareafile::ReadAdeptXbbsFile(char* path, char* file, char* options) {
break;
case CRC_AREAEND:
aa.setechoid(*usenet ? usenet : name);
if(streql(aa.basetype, "OPUS") or streql(aa.basetype, "FTS1"))
if ((aa.basetype == "OPUS") || (aa.basetype == "FTS1"))
aa.setpath(apath);
else {
sprintf(buf, "%s%s", apath, name);

View File

@ -81,7 +81,7 @@ public:
int areaid() const { return cfg.areaid; }
int groupid() const { return cfg.groupid; }
uint type() const { return cfg.type; }
const char *basetype() const { return cfg.basetype; }
const std::string &basetype() const { return cfg.basetype; }
uint board() const { return cfg.board; }
const ftn_addr& aka() const { return cfg.aka; }
int originno() const { return cfg.originno; }
@ -104,6 +104,7 @@ public:
void set_groupid(int g) { cfg.groupid = g; }
void set_type(uint t) { cfg.type = t; }
void set_basetype(const char *m) { cfg.basetype = m; }
void set_basetype(const std::string &m) { cfg.basetype = m; }
void set_board(uint b) { cfg.board = b; }
void set_aka(ftn_addr& a) { cfg.aka = a; }
void set_originno(int o) { cfg.originno = o; }

View File

@ -139,7 +139,7 @@ protected:
FidoWide* wide;
FidoData* data;
inline bool isopus() const { return streql(cfg.basetype, "OPUS"); }
inline bool isopus() const { return (cfg.basetype == "OPUS"); }
void data_open();
void data_close();

View File

@ -55,6 +55,7 @@
#endif
#include <golded3.h>
#include <gmemdbg.h>
// ------------------------------------------------------------------
// Config versions

View File

@ -37,7 +37,7 @@ using namespace std;
#include <gstrall.h>
#include <gftnall.h>
#include <golded3.h>
#include <gmemdbg.h>
int debug = false;