Fixed some memory leaks.

This commit is contained in:
Ianos Gnatiuc 2006-11-25 07:26:20 +00:00
parent 9ff0025e52
commit ffcc586cd5
6 changed files with 105 additions and 14 deletions

View File

@ -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();

View File

@ -29,7 +29,9 @@
// ------------------------------------------------------------------
void ResetMsg(GMsg* msg) {
void ResetMsg(GMsg* msg)
{
msg->link.reset();
throw_xfree(msg->references);
throw_xfree(msg->inreplyto);

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -31,7 +31,7 @@
#if defined(__WIN32__)
#include <windows.h>
#if defined(_MSC_VER) && (_MSC_VER > 1200)
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#include <intrin.h>
#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