[Bf-committers] Proposed changes re: procedural textures

Emil Brink emil at obsession.se
Thu Nov 30 13:48:26 CET 2006


[hash]
> The only ugly thing at the moment:
> The hash_get_sorted_keys() function uses it's own quick-sort
> implementation (the one from
> Wikipedia). Somehow stdlibs qsort didn't work. I don't know what I did
> wrong. I left the qsort call
> as comment in the source, maybe someone knows what's wrong.

Hm ... I replied to this a couple of hours ago, but haven't seen my reply
turn up on the list yet, I suspect there's some issue with my mail. So this
is a second attempt, using webmail instead. Apologies if two replies turn
up.

Anyway, attached is a patch that I believe fixes the issue with qsort().
The problem I think was due to that since you are sorting an array of
pointers (each "element" in qsort's opinion) is a pointer, you get pointers
to pointers in the comparison function. So, you cannot hand qsort() strcmp()
directly, since that requires pointers to the strings. You need a small
glue function between them, that does the dereferencing.

The patch does not remove your q_sort() code, but if it works out for you
now, I guess you should.

I didn't look over the rest of the code, or the API, but what I saw did
look very nice. It was very easy to test this change, thanks to the
existing test program. Well done!

I hope this helps, regards

/Emil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hash-qsort-fix.patch
Type: application/octet-stream
Size: 1078 bytes
Desc: not available
Url : http://projects.blender.org/pipermail/bf-committers/attachments/20061130/ee9c0c40/hash-qsort-fix.obj


More information about the Bf-committers mailing list