Re: [Vala] Custom array free functions



On Tue, 2011-04-26 at 10:57 +0200, Luca Bruno wrote:
On Tue, Apr 26, 2011 at 12:54:13AM +0100, David Given wrote:
Unfortunately this means that when Vala's finished with the array it
will then try to free it with g_free(), which won't work (XFree() and
g_free() may use different heaps). Is there any way to tell Vala that it
should use a specific free function for destroying arrays?

Are you experiencing any crash? XFree() is just Xfree() which is just free().


IMHO it doesn't matter that code does not crash. Consider such code in
90's:

double *tmp = (double *)malloc (20 * sizeof (double))
/// ...

// We need to pass something as int
int i = (int)tmp;

/// ...
double *tmp2 = (double *)i;

It worked back then as sizeof (int) = 32 = sizeof (double *). However
the code is not portable beyond 32-bit architecture or even it may not
port on all 32-bit non-x86 architectures.

For example g_free may or may not be free depending on GMemVTable.

Regards

Attachment: signature.asc
Description: This is a digitally signed message part



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