diff options
-rw-r--r-- | src/plugin.c | 6 | ||||
-rw-r--r-- | src/value.c | 10 | ||||
-rw-r--r-- | src/world.c | 25 |
3 files changed, 19 insertions, 22 deletions
diff --git a/src/plugin.c b/src/plugin.c index 5695794..6e4a28a 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -22,6 +22,9 @@ #include <math.h> #include <stdlib.h> #include <string.h> +#ifdef SLV2_DYN_MANIFEST +#include <dlfcn.h> +#endif #include <librdf.h> #include "slv2/types.h" #include "slv2/collections.h" @@ -30,9 +33,6 @@ #include "slv2/query.h" #include "slv2/util.h" #include "slv2_internal.h" -#ifdef SLV2_DYN_MANIFEST -#include <dlfcn.h> -#endif /* private diff --git a/src/value.c b/src/value.c index ef9f7ff..f4c48df 100644 --- a/src/value.c +++ b/src/value.c @@ -170,7 +170,7 @@ SLV2Value slv2_value_new_int(SLV2World world, int val) { char str[32]; - snprintf(str, 32, "%d", val); + snprintf(str, sizeof(str), "%d", val); SLV2Value ret = slv2_value_new(world, SLV2_VALUE_INT, str); ret->val.int_val = val; return ret; @@ -181,7 +181,7 @@ SLV2Value slv2_value_new_float(SLV2World world, float val) { char str[32]; - snprintf(str, 32, "%f", val); + snprintf(str, sizeof(str), "%f", val); SLV2Value ret = slv2_value_new(world, SLV2_VALUE_FLOAT, str); ret->val.float_val = val; return ret; @@ -259,7 +259,7 @@ slv2_value_get_turtle_token(SLV2Value value) switch (value->type) { case SLV2_VALUE_URI: len = strlen(value->str_val) + 3; - result = calloc(len, sizeof(char)); + result = calloc(len, 1); snprintf(result, len, "<%s>", value->str_val); break; case SLV2_VALUE_STRING: @@ -271,7 +271,7 @@ slv2_value_get_turtle_token(SLV2Value value) // FIXME: locale kludge, need a locale independent snprintf locale = strdup(setlocale(LC_NUMERIC, NULL)); len = 20; - result = calloc(len, sizeof(char)); + result = calloc(len, 1); setlocale(LC_NUMERIC, "POSIX"); snprintf(result, len, "%d", value->val.int_val); setlocale(LC_NUMERIC, locale); @@ -280,7 +280,7 @@ slv2_value_get_turtle_token(SLV2Value value) // FIXME: locale kludge, need a locale independent snprintf locale = strdup(setlocale(LC_NUMERIC, NULL)); len = 20; // FIXME: proper maximum value? - result = calloc(len, sizeof(char)); + result = calloc(len, 1); setlocale(LC_NUMERIC, "POSIX"); snprintf(result, len, "%f", value->val.float_val); setlocale(LC_NUMERIC, locale); diff --git a/src/world.c b/src/world.c index 133384f..0b54f19 100644 --- a/src/world.c +++ b/src/world.c @@ -16,24 +16,21 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "slv2-config.h" - #define _XOPEN_SOURCE 500 -#include <string.h> #include <stdlib.h> #include <dirent.h> #include <wordexp.h> #include <string.h> +#ifdef SLV2_DYN_MANIFEST +#include <dlfcn.h> +#endif #include <librdf.h> #include "slv2/types.h" #include "slv2/world.h" #include "slv2/slv2.h" #include "slv2/util.h" +#include "slv2-config.h" #include "slv2_internal.h" -#ifdef SLV2_DYN_MANIFEST -#include <dlfcn.h> -#endif - /* private */ static SLV2World @@ -291,7 +288,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_free_query(query); #endif // SLV2_DYN_MANIFEST - /* ?plugin a lv2:Plugin */ + // ?plugin a lv2:Plugin librdf_statement* q = librdf_new_statement_from_nodes(world->world, NULL, librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->lv2_plugin_node)); @@ -302,7 +299,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_node* plugin_node = librdf_new_node_from_node(librdf_statement_get_subject(s)); - /* Add ?plugin rdfs:seeAlso <manifest.ttl>*/ + // Add ?plugin rdfs:seeAlso <manifest.ttl> librdf_node* subject = plugin_node; librdf_node* predicate = librdf_new_node_from_uri_string(world->world, (const unsigned char*)(SLV2_NS_RDFS "seeAlso")); @@ -310,7 +307,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) manifest_uri); librdf_model_add(world->model, subject, predicate, object); - /* Add ?plugin slv2:bundleURI <file://some/path> */ + // Add ?plugin slv2:bundleURI <file://some/path> subject = librdf_new_node_from_node(plugin_node); predicate = librdf_new_node_from_uri_string(world->world, (const unsigned char*)(SLV2_NS_SLV2 "bundleURI")); @@ -324,7 +321,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_free_statement(q); - /* ?specification a lv2:Specification */ + // ?specification a lv2:Specification q = librdf_new_statement_from_nodes(world->world, NULL, librdf_new_node_from_node(world->rdf_a_node), librdf_new_node_from_node(world->lv2_specification_node)); @@ -335,7 +332,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_node* spec_node = librdf_new_node_from_node(librdf_statement_get_subject(s)); - /* Add ?specification rdfs:seeAlso <manifest.ttl> */ + // Add ?specification rdfs:seeAlso <manifest.ttl> librdf_node* subject = spec_node; librdf_node* predicate = librdf_new_node_from_uri_string(world->world, (const unsigned char*)(SLV2_NS_RDFS "seeAlso")); @@ -344,7 +341,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_model_add(world->model, subject, predicate, object); - /* Add ?specification slv2:bundleURI <file://some/path> */ + // Add ?specification slv2:bundleURI <file://some/path> subject = librdf_new_node_from_node(spec_node); predicate = librdf_new_node_from_uri_string(world->world, (const unsigned char*)(SLV2_NS_SLV2 "bundleURI")); @@ -357,7 +354,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri) librdf_free_stream(results); librdf_free_statement(q); - /* Join the temporary model to the main model */ + // Join the temporary model to the main model librdf_stream* manifest_stream = librdf_model_as_stream(manifest_model); librdf_model_add_statements(world->model, manifest_stream); librdf_free_stream(manifest_stream); |