Hi Colin,
I've just done a xxdiff between your and the original file and I'm
inclined to think the original code is correct. The code is
dereference of a node_id which is defined by lib3ds as an unsigned
short, so the cast is appropriate.
What doesn't look appropriate is that the return type is a int, while
the parameters in lhs - rhs line are both unsigned. Casting from
unsigned short to int looks more appropriate i.e. replaced the
original code:
static int
compare_node_id( const void *a, const void *b ) {
return (*((Lib3dsNode**)a))->node_id - (*((Lib3dsNode**)b))->node_id;
}
static int
compare_node_id2( const void *a, const void *b ) {
return *((unsigned short*)a) - (*((Lib3dsNode**)b))->node_id;
}
With:
static int
compare_node_id( const void *a, const void *b ) {
return int((*((Lib3dsNode**)a))->node_id) -
int((*((Lib3dsNode**)b))->node_id);
}
static int
compare_node_id2( const void *a, const void *b ) {
return int(*((unsigned short*)a)) - int((*((Lib3dsNode**)b))->node_id);
}
Would make things explict and hopefully avoid potential
misinterpretation my the compiler. Could you try this change at your
end, if it works fine I'll check it in.
Thanks,
Robert.
On Fri, Apr 16, 2010 at 7:40 PM, Colin McDonald
<[email protected]> wrote:
> With the file this time....
>
> Hi Robert,
>
> I've found a problem in the imported lib3ds library on big-endian systems.
> The address of an unsigned int was being cast to the address of an
> unsigned short, which doesn't work when dereferenced on a
> big-endian system.
>
> The attached file fixes the problem, I'll also look into reporting it
> upstream to the lib3ds project.
>
> Regards
>
> Colin McDonald
>
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org