Hi,
I use the canvas_open() function to locate a file (FAUST DSP file) but I don't understand if I should use the close() function on the returning value:
int fd = canvas_open(...); if(fd >= 0) { close(fd); }
This code works well on Linux and Mac but it crashes on Windows. I looked at other uses of the canvas_open() function but they differ. The close() function is used, in the binbuf_read_via_canvas() function (l. 850 of m_binbuf.c) or in the open_soundfile_via_canvas() function (l. 494 of d_soundfile.c). But the returning value is not closed in the bonk_read() function (l. 985 of bonk~.c) or the garray_read() function (l. 1096 of g_array.c).
Is there one case where I should call the close() function and another not. Or is there an error in some of these example? Am I missing something important?
Thanks
On 8/24/18 6:01 PM, Pierre Guillot wrote:
Hi,
I use the canvas_open() function to locate a file (FAUST DSP file) but I don't understand if I should use the close() function on the returning value:
int fd = canvas_open(...); if(fd >= 0) { close(fd); }
This code works well on Linux and Mac but it crashes on Windows. I looked at other uses of the canvas_open() function but they differ. The close() function is used, in the binbuf_read_via_canvas() function (l. 850 of m_binbuf.c) or in the open_soundfile_via_canvas() function (l. 494 of d_soundfile.c). But the returning value is not closed in the bonk_read() function (l. 985 of bonk~.c) or the garray_read() function (l. 1096 of g_array.c).
Is there one case where I should call the close() function and another not. Or is there an error in some of these example? Am I missing something important
use sys_close(). depending on the libc you are linking your external against and the libc Pd is linked to, the filedescriptors returned by canvas_open() might not be compatible with close(). sys_close() uses the correct one.
fgmrdsa IOhannes
Thanks a lot! It works perfectly!
Le ven. 24 août 2018 à 21:43, IOhannes m zmölnig zmoelnig@iem.at a écrit :
On 8/24/18 6:01 PM, Pierre Guillot wrote:
Hi,
I use the canvas_open() function to locate a file (FAUST DSP file) but I don't understand if I should use the close() function on the returning value:
int fd = canvas_open(...); if(fd >= 0) { close(fd); }
This code works well on Linux and Mac but it crashes on Windows. I looked at other uses of the canvas_open() function but they differ. The close() function is used, in the binbuf_read_via_canvas() function (l. 850 of m_binbuf.c) or in the open_soundfile_via_canvas() function (l. 494 of d_soundfile.c). But the returning value is not closed in the bonk_read() function (l. 985 of bonk~.c) or the garray_read() function (l. 1096 of g_array.c).
Is there one case where I should call the close() function and another
not.
Or is there an error in some of these example? Am I missing something important
use sys_close(). depending on the libc you are linking your external against and the libc Pd is linked to, the filedescriptors returned by canvas_open() might not be compatible with close(). sys_close() uses the correct one.
fgmrdsa IOhannes
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev