Is using fine when a library doesn't have its own freeing function?

The XCB library occasionally requires the user to free data by themselves using the libc free function. The documentation on in Julia specifically says it shouldn’t be used to free data from external libraries and to use the memory freeing functions provided by the libraries used. The problem is, as I stated above, XCB does not provide such function. Can I then use for freeing memory it allocates for me, or do I have to live with a memleak?

I believe you have to. There doesn’t appear to be any technical reason memory allocated by one library can’t be deallocated by another. It’s just a very frowned upon interface.

And apparently on Windows it can cause issues.

1 Like

Well, X11 users are most probably on posix platforms so I don’t think I have to worry about that, although wrapping the frees in ifs checking the platform might be a good idea…