C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[63726] Re:Re:TStringList 메모리 누수문제 간단소스코드포함입니다.
헬미 [] 1285 읽음    2011-02-14 21:12
답변 감사드립니다.

말씀하신대로 했는데도 여전히 codeguard를 키면 오류가 납니다. T_T


김태선 님이 쓰신 글 :
: void __fastcall TForm1::Button2Click(TObject *Sender)
: {
:     TStringList  *strList = new TStringList;
:
:     func_root(strList);
:
:     for(int j = 0; j < strList->Count; j++)
:     {
:         TYPESTRUCT *abc = (TYPESTRUCT *)strList->Objects[j];
:
:         Memo1->Lines->Add(abc->age);
:         Memo1->Lines->Add(abc->name);
:         Memo1->Lines->Add("--------");
:
:         //delete abc;
:     }
:
:     while(strList->Count)
:     {
:            delete (TYPESTRUCT *)strList->Objects[0];
:            strList->Delete(0);
:     }
:
:     delete strList;
: }
:
: 헬미 님이 쓰신 글 :
: : 아래 코드를 그냥 실행시키면 오류가 안납니다.
: :
: : codeguard를 키고 실행하면 종료시
: :
: : delete (TYPESTRUCT *)strList->Objects[0];
: : 이부분에서 오류가 나는것 같습니다.
: :
: : 오류 해결방법좀 부탁드릴께요....고수님들 도와주세요
: :
: : //---------------------------------------------------------------------------
: : typedef struct _test
: : {
: :     int    age;
: :     char   name[8];
: : }TYPESTRUCT;
: : //---------------------------------------------------------------------------
: : void __fastcall TForm5::Button1Click(TObject *Sender)
: : {
: :     TStringList  *strList = new TStringList;
: :
: :     func_root(strList);
: :
: :     for(int j = 0; j < strList->Count; j++)
: :     {
: :         TYPESTRUCT *abc = (TYPESTRUCT *)strList->Objects[j];
: :
: :         Memo1->Lines->Add(abc->age);
: :         Memo1->Lines->Add(abc->name);
: :         Memo1->Lines->Add("--------");
: :
: :         delete abc;
: :     }
: :
: :     while(strList->Count)
: :     {
: :            delete (TYPESTRUCT *)strList->Objects[0];
: :            strList->Delete(0);
: :     }   
: : }
: : //---------------------------------------------------------------------------
: : void __fastcall TForm5::func_root(TStringList *strList)
: : {
: :     TYPESTRUCT *ts = new TYPESTRUCT;
: :
: :     objCopy("이름", "홍길동", ts);
: :     objCopy("나이", "18", ts);
: :
: :     strList->AddObject(ts->name, (TObject *)ts);
: : }
: : //---------------------------------------------------------------------------
: : void __fastcall TForm5::objCopy(String name, String value, TYPESTRUCT *ts)
: : {
: :     if(name == "이름")
: :         strcpy(ts->name, value.c_str());
: :     else if (name=="나이")
: :         ts->age = value.ToIntDef(0);
: : }

+ -

관련 글 리스트
63724 TStringList 메모리 누수문제 간단소스코드포함입니다. 헬미 1846 2011/02/14
63725     Re:TStringList 메모리 누수문제 간단소스코드포함입니다. 김태선 1297 2011/02/14
63726         Re:Re:TStringList 메모리 누수문제 간단소스코드포함입니다. 헬미 1285 2011/02/14
63727             Re:Re:Re:TStringList 메모리 누수문제 간단소스코드포함입니다. Nibble 1362 2011/02/15
63741                 Re:Re:Re:Re:TStringList 메모리 누수문제 간단소스코드포함입니다. 김동원 1729 2011/02/16
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.