diff options
author | David Robillard <d@drobilla.net> | 2012-08-02 22:12:06 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-02 22:12:06 +0000 |
commit | 0bb37e7451f42fe82b28145455a71c56c92174b8 (patch) | |
tree | ade81993e9add2e2fdb64555af7a53a437386a79 /src/suil_internal.h | |
parent | 2f49d76d50c658eabd765245b51332924cd62147 (diff) | |
download | suil-0bb37e7451f42fe82b28145455a71c56c92174b8.tar.gz suil-0bb37e7451f42fe82b28145455a71c56c92174b8.tar.bz2 suil-0bb37e7451f42fe82b28145455a71c56c92174b8.zip |
Replace host provided features that match Suil implemented features, rather
than passing UIs duplicate features.
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@4599 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/suil_internal.h')
-rw-r--r-- | src/suil_internal.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/suil_internal.h b/src/suil_internal.h index cca12fa..385dc26 100644 --- a/src/suil_internal.h +++ b/src/suil_internal.h @@ -19,6 +19,7 @@ #include <assert.h> #include <stdlib.h> +#include <string.h> #ifdef _WIN32 #include <windows.h> @@ -101,17 +102,25 @@ suil_dlfunc(void* handle, const char* symbol) /** Add a feature to a (mutable) LV2 feature array. */ static inline void suil_add_feature(LV2_Feature*** features, - unsigned n, + unsigned* n, const char* uri, void* data) { + for (unsigned i = 0; i < *n && (*features)[i]; ++i) { + if (!strcmp((*features)[i]->URI, uri)) { + (*features)[i]->data = data; + return; + } + } + *features = (LV2_Feature**)realloc(*features, - sizeof(LV2_Feature*) * (n + 2)); + sizeof(LV2_Feature*) * (*n + 2)); - (*features)[n] = (LV2_Feature*)malloc(sizeof(LV2_Feature)); - (*features)[n]->URI = uri; - (*features)[n]->data = data; - (*features)[n + 1] = NULL; + (*features)[*n] = (LV2_Feature*)malloc(sizeof(LV2_Feature)); + (*features)[*n]->URI = uri; + (*features)[*n]->data = data; + (*features)[*n + 1] = NULL; + *n += 1; } #endif // SUIL_INTERNAL_H |