IT 취미생활.  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'Programming'에 해당하는 글(80)
2008.03.09   2차 배열 동적 할당 - 일반 및 개선 2
2008.03.09   HEAP[xxxxx.exe]: Invalid allocation size - 90909048
2008.03.08   [VC++] Unicode <--> Ansi 변환 간단


2차 배열 동적 할당 - 일반 및 개선
일반 적인 2차 배열 동적 할당


코드:
template <typename Ty>
Ty **alloc2DArray(int width, int height)
{   
 Ty **arr = new Ty*[height];   
 for(int i=0; i<height; i++)   
 {       
  arr[i] = new Ty[width];  
 }   
 return arr;
}
template <typename Ty>
void free2DArray(Ty **&arr, int height)
{  
 for(int i=0; i<height; i++)   
 {       
  delete []arr[i];       
  arr[i] = 0;   
 }  
 delete []arr;   
 arr = 0;
}


고급
int **imatrix( int w, int h ) 
{
 int i;
 int **m;
 m = new int * [h]; 
 if( !m )
  PutError("memory alloc failure in imatrix()"), exit(0);
 m[0] = new int [ w * h ]; 
 if( !m[0] )
  PutError("memory alloc failure in imatrix()"), exit(0);
 for( i = 1; i < h; i++ ) { 
  m[i] = &m[0][ i * w ];
 }
 return m;
}

고급으로 할당 하는 방법에 대해서 눈여겨 보세요.


HEAP[xxxxx.exe]: Invalid allocation size - 90909048
==== 문제 및 현상 ====
CFileDialog 를 사용하여 파일 Picker를 추가 후, 파일 네비게이션 쪽 을 클릭 하니....
아래와 같은 메시지를 뿜으며 죽었다.


HEAP[test.exe]: Invalid allocation size - 90909048 (exceeded 7ffdefff)
First-chance exception in xxxxx.exe (KERNEL32.DLL): 0x8007000E: (no name).


==== My 문제해결 방법 ====
내 App에서 COM을 사용하여
CoInitializeEx(NULL, COINIT_MULTITHREADED); 를 사용하고 있었음


구글링을 해보니....짱께 싸이트에서.......
CoInitializeEx(0, COINIT_APARTMENTTHREADED);
이용하니 문제 해결


====  Why???? ====
아시는 분은 코멘트 달아주세요.-0- 귀차니즘.


[VC++] Unicode <--> Ansi 변환 간단
char *szMessage = "Hello World";
wchar_t wszMessage[256] = { 0 };
wsprintfW( wszMessage, L"%S", szMessage );

wchar_t *wszMessage= L"Hello World";
char szMessage[256] = { 0 };
wsprintfA( szMessage, "%S", wszMessage );


BLOG main image
취미생활
 Notice
 Category
분류 전체보기 (191)
매일매일갱생 (83)
서버개발 (1)
임베디드개발 (12)
Programming (80)
Personal Projects (6)
유용한 프로그램 (0)
 TAGS
Dshow 출장 warning 서태지 english email spam mail M480 미라지폰 DVB-T 티스토리초대 Java 영어 이메일 C 퇴사 VC++ isdbt Debug 1seg 벨소리 변경 DVB It 개발자 DirectShow English Windows Mobile6.0 ISDB-T 알고리즘 Linux 티스토리 초대장 Algorithm project 음식 Wince5.0 Brazil 군대 C++ MP3 Error Case debugging
 Calendar
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
zextor
괴짜 프로그래머의 일상사~@@
Gag & Peace, and more..
Kazakhstan Almaty.......
Min-A
Sadgarret
Steve Yoon's log
가슴 뛰는 삶을 살아라
오스틴 파워
GUI sin
melanie parker_Lady
제레미의 TV 2.0 이야기..
 Visitor Statistics
Total :
Today :
Yesterday :
rss