That sounds reasonable; any objections to committing it ? :-)
(timeout until Monday ;) )
---------- Forwarded message ----------
Date: Fri, 24 Mar 2006 09:27:15 +0200
From: Tomas Rapkauskas <[EMAIL PROTECTED]>
To: Gernot Ziegler <[EMAIL PROTECTED]>
Subject: Memory leak lib3ds_file_free
Hello,
I have attached a 3ds file to make tests on memory leak detection.
My development tools:
VC 6.0 sp6
lib3ds 1.30 (not sure about version number, but I am using latest
version from CVS)
I am using lib3ds compiled as lib in my own (C++)project without dmalloc.
Now about memory leak:
During load of attached file it is called:
*lib3ds_viewport_set_views* function for the
*file->viewport and*
*file->viewport_keyf => *Here small stack how this member initialized:
0. lib3ds_file_read
1. if (!kfdata_read(file, io)) {
2. if (!lib3ds_viewport_read(&*file->viewport_keyf*, io)) {
3. case LIB3DS_VIEWPORT_DATA_3: {
*lib3ds_viewport_set_views*(*viewport*,cur+1);
4. *viewport*->layout.*viewL*=(Lib3dsView*)*calloc*(sizeof(Lib3dsView),views);
lib3ds_viewport_set_views(Lib3dsViewport *viewport ....
function allocates memory for the viewport:
......
else {
if (views) {
viewport->layout.views=views;
*viewport*->layout.*viewL*=(Lib3dsView*)*calloc*(sizeof(Lib3dsView),views);
}
}
To free Lib3dsFile structure memory I am using:
lib3ds_file_free(Lib3dsFile* file)
implementation of this function deallocates memory only
for the file->viewport:
....
lib3ds_viewport_set_views(&file->viewport,0);
..
So during "load" and "unload" of attached 3ds file I get memory leak
on the lib3ds_viewport_set_views, because after "unload" of file
memory not deallocated for the **file->viewport_keyf.**
My solution:
do add of => lib3ds_viewport_set_views(&file->viewport_keyf,0);
to the lib3ds_file_free function.
Such change avoids memory leak, not sure it is correct,
but it helped for me.
Tomas
P.S. I am not guru of C also of lib3ds
so it can be that I made some there a mistake or I am using
some think not in correct way.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
lib3ds-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel