guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exposing common type wrapping/unwrapping methods


From: Ken Raeburn
Subject: Re: Exposing common type wrapping/unwrapping methods
Date: Sat, 20 Aug 2005 02:01:21 -0400

On Aug 19, 2005, at 03:57, Ludovic Courtès wrote:
+/* Return a newly-allocated `sockaddr' structure that reflects ADDRESS, being + an address of family FAMILY, with the family-specific parameters ARGS (see + the description of `connect' for details). The returned structure may be
+   freed using `free ()'.  */
+struct sockaddr *
+scm_to_sockaddr (int family, SCM address, SCM args)

This reminds me... was there ever a decision on the "call malloc and free from the same object on Windows" issue? I found some old discussion in the guile-devel mail archive in late 2001, between stefan and Dirk mostly, but I don't see a resolution.

Basically, malloc and free referenced from a DLL, say libguile.dll, may be different instances of the functions than the application or other DLLs might see, and they should thus be assumed to have different allocation pools that can't be mixed. If a chunk of storage is allocated by one DLL's notion of "malloc", then it must be freed by that same DLL's notion of "free". (I worded it a little funny here, because function pointers could be passed around such that, for example, the library always uses the application's allocator, or the application can allocate storage from the library's pool; shim functions work too.) Interfaces like this, where the DLL allocates and the main program frees, can cause corruption.

Or, you just don't build DLLs for some packages.

Ken



reply via email to

[Prev in Thread] Current Thread [Next in Thread]