From ffcc586cd51a75d1a44076c2187e6ad299604335 Mon Sep 17 00:00:00 2001 From: Ianos Gnatiuc Date: Sat, 25 Nov 2006 07:26:20 +0000 Subject: [PATCH] Fixed some memory leaks. --- golded3/gecmfd.cpp | 15 +++++--- golded3/gelmsg.cpp | 4 +- golded3/gerand.cpp | 6 ++- golded3/gmarea.cpp | 10 +++-- golded3/gmarea.h | 80 ++++++++++++++++++++++++++++++++++++++- goldlib/gall/gutlvers.cpp | 4 +- 6 files changed, 105 insertions(+), 14 deletions(-) diff --git a/golded3/gecmfd.cpp b/golded3/gecmfd.cpp index fb8059c..0de0007 100644 --- a/golded3/gecmfd.cpp +++ b/golded3/gecmfd.cpp @@ -462,8 +462,10 @@ void CmfMsgs(GMsg* msg, bool torecycle) AL.SetActiveAreaId(OrigArea); AreaData* orig_adat = AA->adat; - AA->adat = (AreaData*)throw_calloc(1, sizeof(AreaData)); - memcpy(AA->adat, orig_adat, sizeof(AreaData)); +// AA->adat = (AreaData*)throw_calloc(1, sizeof(AreaData)); +// memcpy(AA->adat, orig_adat, sizeof(AreaData)); + AA->adat = new AreaData; + *AA->adat = *orig_adat; AL.SetActiveAreaId(destarea); Area* AAdest = AA; @@ -473,9 +475,11 @@ void CmfMsgs(GMsg* msg, bool torecycle) // Is it readonly? if(AA->attr().r_o()) { GMenuReadonly MenuReadonly; - if(not MenuReadonly.Run()) { + if(not MenuReadonly.Run()) + { AL.SetActiveAreaId(OrigArea); - throw_free(AA->adat); +// throw_free(AA->adat); + delete AA->adat; AA->adat = orig_adat; GFTRK(0); return; @@ -681,7 +685,8 @@ void CmfMsgs(GMsg* msg, bool torecycle) // Return to original area and unlock it AL.SetActiveAreaId(OrigArea); - throw_free(AA->adat); +// throw_free(AA->adat); + delete AA->adat; AA->adat = orig_adat; AA->Unlock(); diff --git a/golded3/gelmsg.cpp b/golded3/gelmsg.cpp index c3b52c9..c8a16ed 100644 --- a/golded3/gelmsg.cpp +++ b/golded3/gelmsg.cpp @@ -29,7 +29,9 @@ // ------------------------------------------------------------------ -void ResetMsg(GMsg* msg) { +void ResetMsg(GMsg* msg) +{ + msg->link.reset(); throw_xfree(msg->references); throw_xfree(msg->inreplyto); diff --git a/golded3/gerand.cpp b/golded3/gerand.cpp index 96794e2..e09e30e 100644 --- a/golded3/gerand.cpp +++ b/golded3/gerand.cpp @@ -236,8 +236,10 @@ void Area::InitData() { void Area::RandomizeData(int mode) { - if(not adat) { - adat = (AreaData*)throw_calloc(1, sizeof(AreaData)); + if(not adat) + { +// adat = (AreaData*)throw_calloc(1, sizeof(AreaData)); + adat = new AreaData; InitData(); } else { // reset to global defaults diff --git a/golded3/gmarea.cpp b/golded3/gmarea.cpp index bdaa3fd..6be7c0f 100644 --- a/golded3/gmarea.cpp +++ b/golded3/gmarea.cpp @@ -197,8 +197,10 @@ void RenumberArea() { void Area::Open() { - if(not adat) { - adat = (AreaData*)throw_calloc(1, sizeof(AreaData)); + if(not adat) + { +// adat = (AreaData*)throw_calloc(1, sizeof(AreaData)); + adat = new AreaData; InitData(); } @@ -228,7 +230,9 @@ void Area::Close() { UpdateAreadata(); - throw_release(adat); +// throw_release(adat); + delete adat; + adat = 0; } diff --git a/golded3/gmarea.h b/golded3/gmarea.h index e8b6fd0..8858a16 100644 --- a/golded3/gmarea.h +++ b/golded3/gmarea.h @@ -260,7 +260,85 @@ int AreaCmp(const Area** __a, const Area** __b); // ------------------------------------------------------------------ // Area data (collected from global/Random System) -struct AreaData { +struct AreaData +{ + AreaData() + { + akamatching = false; + areacopyaddid = false; + areacopydirect = false; + areaforwarddirect = false; + areafreqdirect = false; + areareplydirect = false; + dispsoftcr = false; + edithardterm = false; + editmixcase = false; + forcetemplate = false; + hidestylies = false; + usestylies = false; + internetmsgid = false; + msglistfast = false; + msglistfirst = false; + msglistheader = false; + msglistwidesubj = false; + quotewraphard = false; + taglinesupport = false; + templatematch = false; + usearea = false; + usesoftcrxlat = false; + usetzutc = false; + inittwit = false; + viewhidden = false; + viewkludge = false; + viewquote = false; + striphtml = false; + + ctrlinfo = 0; + internetrfcbody = 0; + msglistdate = 0; + quotectrl = 0; + replyre = 0; + usefwd = 0; + twitmode = 0; + writeheader = 0; + + taglinechar = 0; + + memset(origin, 0, sizeof(origin)); + memset(quotechars, 0, sizeof(quotechars)); + memset(quotestring, 0, sizeof(quotestring)); + memset(quotestops, 0, sizeof(quotestops)); +#if defined(GCFG_SPELL_INCLUDED) + memset(scheckerdeflang, 0, sizeof(scheckerdeflang)); +#endif + memset(tagline, 0, sizeof(tagline)); + memset(areacopyto, 0, sizeof(areacopyto)); + memset(areafreqto, 0, sizeof(areafreqto)); + memset(areareplyto, 0, sizeof(areareplyto)); + memset(areayouwroteto, 0, sizeof(areayouwroteto)); + memset(loadlanguage, 0, sizeof(loadlanguage)); + memset(quotebuffile, 0, sizeof(quotebuffile)); + memset(tpl, 0, sizeof(tpl)); + memset(wtpl, 0, sizeof(wtpl)); + memset(inputfile, 0, sizeof(inputfile)); + memset(outputfile, 0, sizeof(outputfile)); + memset(internetaddress, 0, sizeof(internetaddress)); + memset(whoto, 0, sizeof(whoto)); + memset(nickname, 0, sizeof(nickname)); + memset(netname, 0, sizeof(netname)); + memset(organization, 0, sizeof(organization)); + memset(searchfor, 0, sizeof(searchfor)); + memset(tearline, 0, sizeof(tearline)); + memset(xlatexport, 0, sizeof(xlatexport)); + memset(xlatimport, 0, sizeof(xlatimport)); + + //classes + memset(&aka, 0, sizeof(aka)); + memset(&attributes, 0, sizeof(attributes)); + memset(&internetgate, 0, sizeof(internetgate)); + memset(&play, 0, sizeof(play)); + memset(&username, 0, sizeof(username)); + } // Area gaka aka; diff --git a/goldlib/gall/gutlvers.cpp b/goldlib/gall/gutlvers.cpp index 49c0833..6c91584 100644 --- a/goldlib/gall/gutlvers.cpp +++ b/goldlib/gall/gutlvers.cpp @@ -31,7 +31,7 @@ #if defined(__WIN32__) #include -#if defined(_MSC_VER) && (_MSC_VER > 1200) +#if defined(_MSC_VER) && (_MSC_VER >= 1400) #include #endif #elif defined(__GNUC__) @@ -52,7 +52,7 @@ // ------------------------------------------------------------------ -#if defined(_MSC_VER) && (_MSC_VER <= 1200) +#if defined(_MSC_VER) && (_MSC_VER < 1400) static void __cpuid(int CPUInfo[4], int cpuidfun) { __asm