Re: [PATCH 5/5] d3drm: Assign animation key ids
On 10 July 2017 at 12:40, Nikolay Sivov <nsivov(a)codeweavers.com> wrote:
+static BOOL d3drm_animation_get_next_key_id(struct d3drm_animation_keys *keys, DWORD *id) +{ + DWORD i; + + if (keys->next_unused <= keys->last_id) + { + *id = keys->next_unused++; + return TRUE; + } + + if (keys->next_free <= keys->last_id) + { + *id = keys->next_free; + keys->next_free = ~0u; + return TRUE; + } + + if (keys->count == keys->last_id - keys->first_id + 1) + return FALSE; + + /* Worst case, look for the spot from the beginning. */ + for (i = 0, *id = keys->first_id; i < keys->count; i++, ++*id) + { + if (*id != keys->keys[i].id) + break; + } Does that work? The keys aren't necessarily ordered by ID, right? Regardless, it may be easier to make use of the fact that we never shrink the keys array.
participants (1)
-
Henri Verbeet