summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-06-21 21:00:01 +0200
committerDavid Robillard <d@drobilla.net>2019-06-21 21:00:01 +0200
commit630ee8c69bb755cf3b3882554602f249e7757964 (patch)
treec09842183bc6902cceec1bc84f9685cdc5110e5f
parent0f4053d845ffe0daedeaa953e58614491ebc871d (diff)
downloadlilv-630ee8c69bb755cf3b3882554602f249e7757964.tar.gz
lilv-630ee8c69bb755cf3b3882554602f249e7757964.tar.bz2
lilv-630ee8c69bb755cf3b3882554602f249e7757964.zip
Factor out state property searching
-rw-r--r--src/state.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/state.c b/src/state.c
index 57c4b86..e5c789b 100644
--- a/src/state.c
+++ b/src/state.c
@@ -171,6 +171,18 @@ append_property(LilvState* state,
prop->flags = flags;
}
+static const Property*
+find_property(const LilvState* const state, const uint32_t key)
+{
+ const Property search_key = {NULL, 0, key, 0, 0};
+
+ return (const Property*)bsearch(&search_key,
+ state->props.props,
+ state->props.n,
+ sizeof(Property),
+ property_cmp);
+}
+
static LV2_State_Status
store_callback(LV2_State_Handle handle,
uint32_t key,
@@ -191,11 +203,7 @@ retrieve_callback(LV2_State_Handle handle,
uint32_t* type,
uint32_t* flags)
{
- const LilvState* const state = (LilvState*)handle;
- const Property search_key = { NULL, 0, key, 0, 0 };
- const Property* const prop = (Property*)bsearch(
- &search_key, state->props.props, state->props.n,
- sizeof(Property), property_cmp);
+ const Property* const prop = find_property((const LilvState*)handle, key);
if (prop) {
*size = prop->size;