xrealloc size is 0?
Eric Frias
efrias at syncad.com
Mon Apr 18 14:06:56 CDT 2005
Mark Greenbank wrote:
> Still trying to compile wine for Solaris 10 but this time I'm getting
> a message during the build that virtual memory has been exhausted.
>
> I traced this to an xrealloc call requesting a realloc of 0 size;
> could this be correct?
I've seen this bug before. The behavior of realloc(ptr, 0) is
undefined, but linux lets you do it so it wasn't caught. Solaris isn't
so forgiving. Neither is HPUX, for that matter.
According to the spec (found this online, I think it's quoting C99:
If the size of the space requested is
zero, the behavior is implementation-defined: either a null
pointer is returned, or the behavior is as if the size were
some nonzero value, except that the returned pointer shall
not be used to access an object.
You're probably seeing this error in tools/winebuild/import.c, there's a
line:
imp->exports = xrealloc( imp->exports, imp->nb_exports *
sizeof(*imp->exports) );
that triggers this on solaris. You should change it to:
imp->exports = xrealloc( imp->exports, imp->nb_exports ?
(imp->nb_exports * sizeof(*imp->exports)) : 1 );
or something similar to get it to work.
BTW, this is one of several patches I sent to wine-patches around Nov 17
of last year, most of which were fixes to get wine working correctly on
sparc/solaris. I don't know how many of these patches actually made it
into the main CVS. You might want to check them out if you run into
more problems (especially if you're on sparc, a lot of the bugs were
endian-ness and probably didn't affect x86 solaris).
Eric
More information about the wine-devel
mailing list