함수내에서 cvReleaseImage, cvLoadImage 하면 메모리 에러나는듯?
void func(IplImage* test)
{
cvReleaseImage(&test);
test = cvLoadImage(...);
}
int main(void)
{
IplImage* ipl = cvCreateImage(...);
func(ipl);
}
이러고 함수 종료하면 에러남
둘 중에 머가 문제일까?
어쨌든 아래와 같이 수정하니깐 됨
void func(IplImage** test)
{
cvReleaseImage(test);
*test = cvLoadImage(...);
}
int main(void)
{
IplImage* ipl = cvCreateImage(...);
func(&ipl);
}
//IplImage* current
//func(¤t); 수행
-> current 6eaff0
¤t 26f918
//IplImage** param로 받음
->
param 26f918 -> IplImage* 변수 current의 주소
&(*param) 26f918 -> IplImage* 변수 current의 주소
¶m 26f670 -> IplImage** 변수 param의 주소
*param 6eaff0 ->IplImage* 변수 current가 가리키는 곳의 주소
//함수 내 release후
->
param 26f918 -> IplImage* 변수 current의 주소
&(*param) 26f918 -> IplImage* 변수 current의 주소
¶m 26f670 -> IplImage** 변수 param의 주소
*param 3928620 ->IplImage* 변수 current가 가리키는 곳의 주소
어쨌든 소스 자체는 잘못된게 없음
*로는 안되고 **는 안되는 이유는...어쨌든 cvloadimage할 때 문제인거 같다
이해가 안되긴 하지만...