diff --git a/src/rasqal_algebra.c b/src/rasqal_algebra.c index d00df65a..a5a421c9 100644 --- a/src/rasqal_algebra.c +++ b/src/rasqal_algebra.c @@ -61,8 +61,7 @@ rasqal_new_algebra_node(rasqal_query* query, rasqal_algebra_node_operator op) if(!query) return NULL; - node = (rasqal_algebra_node*)RASQAL_CALLOC(rasqal_algebra, 1, - sizeof(rasqal_algebra_node)); + node = RASQAL_CALLOC(rasqal_algebra_node*, 1, sizeof(*node)); if(!node) return NULL; @@ -1552,7 +1551,7 @@ rasqal_algebra_extract_aggregate_expression_visit(void *user_data, /* If not an error, create a new internal variable name for it * $$agg{id}$$ and add it to the map. */ - var_name = (char*)RASQAL_MALLOC(cstring, 20); + var_name = RASQAL_MALLOC(char*, 20); if(!var_name) { ae->error = 1; return 1; @@ -1787,8 +1786,7 @@ rasqal_algebra_query_prepare_aggregates(rasqal_query* query, { rasqal_algebra_aggregate* ae; - ae = (rasqal_algebra_aggregate*)RASQAL_CALLOC(rasqal_algebra_aggregate, - sizeof(*ae), 1); + ae = RASQAL_CALLOC(rasqal_algebra_aggregate*, sizeof(*ae), 1); if(!ae) return NULL; diff --git a/src/rasqal_bindings.c b/src/rasqal_bindings.c index 6e345974..075d857c 100644 --- a/src/rasqal_bindings.c +++ b/src/rasqal_bindings.c @@ -62,8 +62,7 @@ rasqal_new_bindings(rasqal_query* query, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(query, rasqal_query, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(variables, raptor_sequence, NULL); - bindings = (rasqal_bindings*)RASQAL_CALLOC(rasqal_bindings, - 1, sizeof(*bindings)); + bindings = RASQAL_CALLOC(rasqal_bindings*, 1, sizeof(*bindings)); if(!bindings) return NULL; diff --git a/src/rasqal_data_graph.c b/src/rasqal_data_graph.c index a80a4485..d78e6e63 100644 --- a/src/rasqal_data_graph.c +++ b/src/rasqal_data_graph.c @@ -52,7 +52,7 @@ rasqal_new_data_graph_common(rasqal_world* world, { rasqal_data_graph* dg; - dg = (rasqal_data_graph*)RASQAL_CALLOC(rasqal_data_graph, 1, sizeof(*dg)); + dg = RASQAL_CALLOC(rasqal_data_graph*, 1, sizeof(*dg)); if(dg) { dg->world = world; @@ -70,7 +70,7 @@ rasqal_new_data_graph_common(rasqal_world* world, if(format_type) { size_t len = strlen(format_type); - dg->format_type = (char*)RASQAL_MALLOC(string, len + 1); + dg->format_type = RASQAL_MALLOC(char*, len + 1); if(!dg->format_type) goto error; @@ -79,7 +79,7 @@ rasqal_new_data_graph_common(rasqal_world* world, if(format_name) { size_t len = strlen(format_name); - dg->format_name = (char*)RASQAL_MALLOC(string, len + 1); + dg->format_name = RASQAL_MALLOC(char*, len + 1); if(!dg->format_name) goto error; @@ -213,9 +213,9 @@ rasqal_free_data_graph(rasqal_data_graph* dg) if(dg->name_uri) raptor_free_uri(dg->name_uri); if(dg->format_type) - RASQAL_FREE(cstring, dg->format_type); + RASQAL_FREE(char*, dg->format_type); if(dg->format_name) - RASQAL_FREE(cstring, dg->format_name); + RASQAL_FREE(char*, dg->format_name); if(dg->format_uri) raptor_free_uri(dg->format_uri); if(dg->base_uri) diff --git a/src/rasqal_dataset.c b/src/rasqal_dataset.c index c25b1c38..259e55e5 100644 --- a/src/rasqal_dataset.c +++ b/src/rasqal_dataset.c @@ -101,7 +101,7 @@ rasqal_new_dataset(rasqal_world* world) if(!world) return NULL; - ds = (rasqal_dataset*)RASQAL_CALLOC(rasqal_dataset, 1, sizeof(*ds)); + ds = RASQAL_CALLOC(rasqal_dataset*, 1, sizeof(*ds)); if(!ds) return NULL; @@ -153,8 +153,7 @@ rasqal_dataset_statement_handler(void *user_data, ds = (rasqal_dataset*)user_data; - triple = (rasqal_dataset_triple*)RASQAL_MALLOC(rasqal_dataset_triple, - sizeof(*triple)); + triple = RASQAL_MALLOC(rasqal_dataset_triple*, sizeof(*triple)); triple->next = NULL; triple->triple = raptor_statement_as_rasqal_triple(ds->world, statement); @@ -242,8 +241,7 @@ rasqal_dataset_init_match_internal(rasqal_dataset* ds, if(!ds) return NULL; - iter = (rasqal_dataset_term_iterator*)RASQAL_CALLOC(rasqal_dataset_term_iterator, - 1, sizeof(*iter)); + iter = RASQAL_CALLOC(rasqal_dataset_term_iterator*, 1, sizeof(*iter)); if(!iter) return NULL; diff --git a/src/rasqal_datetime.c b/src/rasqal_datetime.c index 2dba5653..fb103703 100644 --- a/src/rasqal_datetime.c +++ b/src/rasqal_datetime.c @@ -532,7 +532,7 @@ rasqal_new_xsd_datetime(rasqal_world* world, const char *datetime_string) rasqal_xsd_datetime* dt; int rc = 0; - dt = (rasqal_xsd_datetime*)RASQAL_MALLOC(datetime, sizeof(*dt)); + dt = RASQAL_MALLOC(rasqal_xsd_datetime*, sizeof(*dt)); if(!dt) return NULL; @@ -563,7 +563,7 @@ rasqal_new_xsd_datetime_from_unixtime(rasqal_world* world, time_t secs) rasqal_xsd_datetime* dt; int rc = 0; - dt = (rasqal_xsd_datetime*)RASQAL_MALLOC(datetime, sizeof(*dt)); + dt = RASQAL_MALLOC(rasqal_xsd_datetime*, sizeof(*dt)); if(!dt) return NULL; @@ -592,7 +592,7 @@ rasqal_new_xsd_datetime_from_timeval(rasqal_world* world, struct timeval *tv) rasqal_xsd_datetime* dt; int rc = 0; - dt = (rasqal_xsd_datetime*)RASQAL_MALLOC(datetime, sizeof(*dt)); + dt = RASQAL_MALLOC(rasqal_xsd_datetime*, sizeof(*dt)); if(!dt) return NULL; @@ -727,7 +727,7 @@ rasqal_xsd_datetime_to_counted_string(const rasqal_xsd_datetime *dt, /* error? */ if(r < 0) { if(ret) - RASQAL_FREE(cstring, ret); + RASQAL_FREE(char*, ret); return NULL; } @@ -736,7 +736,7 @@ rasqal_xsd_datetime_to_counted_string(const rasqal_xsd_datetime *dt, if(len_p) *len_p = r; - ret = (char*)RASQAL_MALLOC(cstring, ++r); + ret = RASQAL_MALLOC(char*, ++r); if(!ret) return NULL; } @@ -953,13 +953,13 @@ rasqal_xsd_date_to_string(const rasqal_xsd_date *d) /* error? */ if(r < 0) { if(ret) - RASQAL_FREE(cstring, ret); + RASQAL_FREE(char*, ret); return NULL; } /* alloc return buffer on first pass */ if(!i) { - ret = (char*)RASQAL_MALLOC(cstring, ++r); + ret = RASQAL_MALLOC(char*, ++r); if(!ret) return NULL; } @@ -1210,7 +1210,7 @@ rasqal_xsd_datetime_get_as_timeval(rasqal_xsd_datetime *dt) if(!dt) return NULL; - tv =(struct timeval*) RASQAL_CALLOC(timeval, 1, sizeof(*tv)); + tv = RASQAL_CALLOC(struct timeval*, 1, sizeof(*tv)); if(!tv) return NULL; @@ -1255,7 +1255,7 @@ rasqal_xsd_datetime_get_timezone_as_counted_string(rasqal_xsd_datetime *dt, if(!dt) return NULL; - tz_str = (char*)RASQAL_MALLOC(cstring, TZ_STR_SIZE + 1); + tz_str = RASQAL_MALLOC(char*, TZ_STR_SIZE + 1); if(!tz_str) return NULL; @@ -1330,7 +1330,7 @@ rasqal_xsd_datetime_get_tz_as_counted_string(rasqal_xsd_datetime* dt, { char* s; - s = (char*)RASQAL_MALLOC(cstring, TIMEZONE_BUFFER_LEN); + s = RASQAL_MALLOC(char*, TIMEZONE_BUFFER_LEN); if(!s) return NULL; @@ -1343,7 +1343,7 @@ rasqal_xsd_datetime_get_tz_as_counted_string(rasqal_xsd_datetime* dt, return s; failed: - RASQAL_FREE(cstring, s); + RASQAL_FREE(char*, s); return NULL; } @@ -1373,7 +1373,7 @@ static int test_datetime_parser_tostring(const char *in_str, const char *out_exp r = strcmp((char*)s, out_expected); if(r) fprintf(stderr, "input dateTime \"%s\" converted to canonical \"%s\", expected \"%s\"\n", in_str, s, out_expected); - RASQAL_FREE(cstring, (void*)s); + RASQAL_FREE(char*, s); } else fprintf(stderr, "input dateTime \"%s\" converted to canonical (null), expected \"%s\"\n", in_str, out_expected); return r; @@ -1389,7 +1389,7 @@ static int test_date_parser_tostring(const char *in_str, const char *out_expecte r = strcmp((char*)s, out_expected); if(r) fprintf(stderr, "input date \"%s\" converted to canonical \"%s\", expected \"%s\"\n", in_str, s, out_expected); - RASQAL_FREE(cstring, (void*)s); + RASQAL_FREE(char*, s); } else fprintf(stderr, "input date \"%s\" converted to canonical (null), expected \"%s\"\n", in_str, out_expected); return r; diff --git a/src/rasqal_decimal.c b/src/rasqal_decimal.c index ad5ab33d..6e2a0116 100644 --- a/src/rasqal_decimal.c +++ b/src/rasqal_decimal.c @@ -113,7 +113,8 @@ rasqal_xsd_decimal* rasqal_new_xsd_decimal(rasqal_world* world) { rasqal_xsd_decimal* dec; - dec = (rasqal_xsd_decimal*)RASQAL_MALLOC(decimal, sizeof(rasqal_xsd_decimal)); + + dec = RASQAL_MALLOC(rasqal_xsd_decimal*, sizeof(*dec)); if(dec) rasqal_xsd_decimal_init(dec); return dec; @@ -178,7 +179,7 @@ static void rasqal_xsd_decimal_clear_string(rasqal_xsd_decimal* dec) { if(dec->string) { - RASQAL_FREE(cstring, dec->string); + RASQAL_FREE(char*, dec->string); dec->string=NULL; } dec->string_len=0; @@ -224,7 +225,7 @@ rasqal_xsd_decimal_set_string(rasqal_xsd_decimal* dec, const char* string) rasqal_xsd_decimal_clear_string(dec); len = strlen(string); - dec->string = (char*)RASQAL_MALLOC(cstring, len+1); + dec->string = RASQAL_MALLOC(char*, len + 1); if(!dec->string) return 1; @@ -428,7 +429,7 @@ rasqal_xsd_decimal_as_string(rasqal_xsd_decimal* dec) /* decimal snprintf with no buffer to get buffer length */ len = DECIMAL_SNPRINTF(NULL, 0, fmt, dec->raw); - s = (char*)RASQAL_MALLOC(cstring, len + 1); + s = RASQAL_MALLOC(char*, len + 1); if(!s) return NULL; diff --git a/src/rasqal_engine_sort.c b/src/rasqal_engine_sort.c index 9c1d034b..030f13f4 100644 --- a/src/rasqal_engine_sort.c +++ b/src/rasqal_engine_sort.c @@ -57,7 +57,7 @@ rasqal_engine_rowsort_free_compare_data(const void* user_data) { rowsort_compare_data* rcd = (rowsort_compare_data*)user_data; - RASQAL_FREE(rowsort_compare_data, rcd); + RASQAL_FREE(rowsort_compare_data, rcd); } @@ -137,8 +137,7 @@ rasqal_engine_new_rowsort_map(int is_distinct, int compare_flags, { rowsort_compare_data* rcd; - rcd = (rowsort_compare_data*)RASQAL_MALLOC(rowsort_compare_data, - sizeof(rowsort_compare_data)); + rcd = RASQAL_MALLOC(rowsort_compare_data*, sizeof(*rcd)); if(!rcd) return NULL; diff --git a/src/rasqal_expr.c b/src/rasqal_expr.c index 15f257a1..0c5c8137 100644 --- a/src/rasqal_expr.c +++ b/src/rasqal_expr.c @@ -78,7 +78,7 @@ rasqal_new_0op_expression(rasqal_world* world, rasqal_op op) RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -126,7 +126,7 @@ rasqal_new_1op_expression(rasqal_world* world, rasqal_op op, goto tidy; } - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -175,7 +175,7 @@ rasqal_new_2op_expression(rasqal_world* world, if(!world || !arg1 || !arg2) goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -222,7 +222,7 @@ rasqal_new_3op_expression(rasqal_world* world, if(!world || !arg1 || !arg2) /* arg3 may be NULL */ goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -271,7 +271,7 @@ rasqal_new_string_op_expression(rasqal_world* world, if(!world || !arg1 || !literal) goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -308,7 +308,7 @@ rasqal_new_literal_expression(rasqal_world* world, rasqal_literal *literal) if(!world || !literal) return NULL; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -335,7 +335,7 @@ rasqal_new_function_expression_common(rasqal_world* world, if(!world || (arg1 && args) || (name && !args)|| (!name && args)) goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -437,7 +437,7 @@ rasqal_new_cast_expression(rasqal_world* world, raptor_uri* name, if(!world || !name || !value) goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -478,7 +478,7 @@ rasqal_new_expr_seq_expression(rasqal_world* world, if(!world || !args) goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -517,7 +517,7 @@ rasqal_new_set_expression(rasqal_world* world, rasqal_op op, if(!world || !arg1 || !args) goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -562,7 +562,7 @@ rasqal_new_group_concat_expression(rasqal_world* world, if(!world || !args) goto tidy; - e = (rasqal_expression*)RASQAL_CALLOC(rasqal_expression, 1, sizeof(*e)); + e = RASQAL_CALLOC(rasqal_expression*, 1, sizeof(*e)); if(e) { e->usage = 1; e->world = world; @@ -2187,8 +2187,7 @@ rasqal_expression_convert_aggregate_to_variable(rasqal_expression* e_in, world = e_in->world; if(e_out) { - *e_out = (rasqal_expression*)RASQAL_MALLOC(rasqal_expression, - sizeof(**e_out)); + *e_out = RASQAL_MALLOC(rasqal_expression*, sizeof(**e_out)); if(!*e_out) goto tidy; } @@ -2243,7 +2242,7 @@ rasqal_new_evaluation_context(rasqal_world* world, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - eval_context = (rasqal_evaluation_context*)RASQAL_CALLOC(rasqal_evaluation_context, 1, sizeof(*eval_context)); + eval_context = RASQAL_CALLOC(rasqal_evaluation_context*, 1, sizeof(*eval_context)); if(!eval_context) return NULL; diff --git a/src/rasqal_expr_datetimes.c b/src/rasqal_expr_datetimes.c index 889c75bc..bc2cfb83 100644 --- a/src/rasqal_expr_datetimes.c +++ b/src/rasqal_expr_datetimes.c @@ -295,7 +295,7 @@ rasqal_expression_evaluate_datetime_timezone(rasqal_expression *e, *error_p = 1; if(s) - RASQAL_FREE(cstring, s); + RASQAL_FREE(char*, s); if(l) rasqal_free_literal(l); diff --git a/src/rasqal_expr_evaluate.c b/src/rasqal_expr_evaluate.c index 53c50afa..8ce0d496 100644 --- a/src/rasqal_expr_evaluate.c +++ b/src/rasqal_expr_evaluate.c @@ -172,7 +172,7 @@ rasqal_expression_evaluate_strdt(rasqal_expression *e, goto failed; } - new_s =(unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_s =RASQAL_MALLOC(unsigned char*, len + 1); if(!new_s) goto failed; memcpy(new_s, s, len + 1); @@ -190,7 +190,7 @@ rasqal_expression_evaluate_strdt(rasqal_expression *e, *error_p = 1; if(new_s) - RASQAL_FREE(cstring, new_s); + RASQAL_FREE(char*, new_s); if(l1) rasqal_free_literal(l1); if(l2) @@ -247,12 +247,12 @@ rasqal_expression_evaluate_strlang(rasqal_expression *e, if(*error_p) goto failed; - new_s = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(!new_s) goto failed; memcpy(new_s, s, len + 1); - new_lang = (unsigned char*)RASQAL_MALLOC(cstring, lang_len + 1); + new_lang = RASQAL_MALLOC(unsigned char*, lang_len + 1); if(!new_lang) goto failed; memcpy(new_lang, lang, lang_len + 1); @@ -270,7 +270,7 @@ rasqal_expression_evaluate_strlang(rasqal_expression *e, *error_p = 1; if(new_s) - RASQAL_FREE(cstring, new_s); + RASQAL_FREE(char*, new_s); if(l1) rasqal_free_literal(l1); if(l2) @@ -610,7 +610,7 @@ rasqal_expression_evaluate_str(rasqal_expression *e, if(!s || *error_p) goto failed; - new_s = (unsigned char *)RASQAL_MALLOC(cstring, len + 1); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(!new_s) goto failed; @@ -675,13 +675,13 @@ rasqal_expression_evaluate_lang(rasqal_expression *e, if(l1->language) { size_t len = strlen(l1->language); - new_s = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(!new_s) goto failed; memcpy((char*)new_s, l1->language, len + 1); } else { - new_s = (unsigned char*)RASQAL_MALLOC(cstring, 1); + new_s = RASQAL_MALLOC(unsigned char*, 1); if(!new_s) goto failed; @@ -855,7 +855,7 @@ rasqal_expression_evaluate_bnode_constructor(rasqal_expression *e, if(*error_p) goto failed; - new_s = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(!new_s) goto failed; diff --git a/src/rasqal_expr_numerics.c b/src/rasqal_expr_numerics.c index 234de840..56bd1e97 100644 --- a/src/rasqal_expr_numerics.c +++ b/src/rasqal_expr_numerics.c @@ -270,7 +270,7 @@ rasqal_expression_evaluate_digest(rasqal_expression *e, unsigned char *new_s; size_t len; int output_len; - const unsigned char *output = NULL; + unsigned char *output = NULL; unsigned int i; unsigned char* p; @@ -292,7 +292,7 @@ rasqal_expression_evaluate_digest(rasqal_expression *e, if(output_len < 0) return NULL; - output = (unsigned char *)RASQAL_MALLOC(char, output_len); + output = RASQAL_MALLOC(unsigned char*, output_len); if(!output) return NULL; @@ -300,7 +300,7 @@ rasqal_expression_evaluate_digest(rasqal_expression *e, if(output_len < 0) goto failed; - new_s = (unsigned char*)RASQAL_MALLOC(cstring, (output_len * 2) + 1); + new_s = RASQAL_MALLOC(unsigned char*, (output_len * 2) + 1); if(!new_s) goto failed; diff --git a/src/rasqal_expr_strings.c b/src/rasqal_expr_strings.c index e880f23d..93bc8694 100644 --- a/src/rasqal_expr_strings.c +++ b/src/rasqal_expr_strings.c @@ -245,7 +245,7 @@ rasqal_expression_evaluate_substr(rasqal_expression *e, } - new_s = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(!new_s) goto failed; @@ -256,7 +256,7 @@ rasqal_expression_evaluate_substr(rasqal_expression *e, if(l1->language) { len = strlen((const char*)l1->language); - new_lang = (char*)RASQAL_MALLOC(cstring, len + 1); + new_lang = RASQAL_MALLOC(char*, len + 1); if(!new_lang) goto failed; @@ -324,7 +324,7 @@ rasqal_expression_evaluate_set_case(rasqal_expression *e, if(*error_p) goto failed; - new_s =(unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_s =RASQAL_MALLOC(unsigned char*, len + 1); if(!new_s) goto failed; @@ -351,7 +351,7 @@ rasqal_expression_evaluate_set_case(rasqal_expression *e, if(l1->language) { len = strlen((const char*)l1->language); - new_lang = (char*)RASQAL_MALLOC(cstring, len + 1); + new_lang = RASQAL_MALLOC(char*, len + 1); if(!new_lang) goto failed; @@ -374,9 +374,9 @@ rasqal_expression_evaluate_set_case(rasqal_expression *e, *error_p = 1; if(new_s) - RASQAL_FREE(cstring, new_s); + RASQAL_FREE(char*, new_s); if(new_lang) - RASQAL_FREE(cstring, new_lang); + RASQAL_FREE(char*, new_lang); if(l1) rasqal_free_literal(l1); @@ -566,7 +566,7 @@ rasqal_expression_evaluate_encode_for_uri(rasqal_expression *e, goto failed; /* pessimistically assume every UTF-8 byte is %XX 3 x len */ - new_s = (unsigned char*)RASQAL_MALLOC(cstring, (3 * len) + 1); + new_s = RASQAL_MALLOC(unsigned char*, (3 * len) + 1); if(!new_s) goto failed; @@ -608,7 +608,7 @@ rasqal_expression_evaluate_encode_for_uri(rasqal_expression *e, *error_p = 1; if(new_s) - RASQAL_FREE(cstring, new_s); + RASQAL_FREE(char*, new_s); if(l1) rasqal_free_literal(l1); @@ -694,7 +694,7 @@ rasqal_expression_evaluate_concat(rasqal_expression *e, len = raptor_stringbuffer_length(sb); - result_str = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + result_str = RASQAL_MALLOC(unsigned char*, len + 1); if(!result_str) goto failed; @@ -714,7 +714,7 @@ rasqal_expression_evaluate_concat(rasqal_expression *e, if(dt) raptor_free_uri(dt); if(result_str) - RASQAL_FREE(cstring, result_str); + RASQAL_FREE(char*, result_str); if(sb) raptor_free_stringbuffer(sb); if(result) diff --git a/src/rasqal_format_rdf.c b/src/rasqal_format_rdf.c index bed034b7..ecb53c2b 100644 --- a/src/rasqal_format_rdf.c +++ b/src/rasqal_format_rdf.c @@ -574,7 +574,7 @@ rasqal_rowsource_rdf_process(rasqal_rowsource_rdf_context* con) unsigned char* var_name; rasqal_variable *v; - var_name = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + var_name = RASQAL_MALLOC(unsigned char*, len + 1); memcpy(var_name, name, len + 1); v = rasqal_variables_table_add(con->vars_table, @@ -771,7 +771,7 @@ rasqal_query_results_rdf_get_rowsource(rasqal_query_results_formatter* formatter { rasqal_rowsource_rdf_context* con; - con = (rasqal_rowsource_rdf_context*)RASQAL_CALLOC(rasqal_rowsource_rdf_context, 1, sizeof(*con)); + con = RASQAL_CALLOC(rasqal_rowsource_rdf_context*, 1, sizeof(*con)); if(!con) return NULL; diff --git a/src/rasqal_format_sparql_xml.c b/src/rasqal_format_sparql_xml.c index 50b5c541..7b07d837 100644 --- a/src/rasqal_format_sparql_xml.c +++ b/src/rasqal_format_sparql_xml.c @@ -585,7 +585,7 @@ rasqal_sparql_xml_sax2_start_element_handler(void *user_data, unsigned char* var_name; rasqal_variable *v; - var_name = (unsigned char*)RASQAL_MALLOC(cstring, con->name_length+1); + var_name = RASQAL_MALLOC(unsigned char*, con->name_length + 1); memcpy(var_name, con->name, con->name_length + 1); v = rasqal_variables_table_add(con->vars_table, @@ -647,7 +647,7 @@ rasqal_sparql_xml_sax2_characters_handler(void *user_data, con->state == STATE_uri || con->state == STATE_bnode) { con->value_len=len; - con->value=(char*)RASQAL_MALLOC(cstring, len+1); + con->value = RASQAL_MALLOC(char*, len + 1); memcpy(con->value, s, len); con->value[len]='\0'; } @@ -703,13 +703,13 @@ rasqal_sparql_xml_sax2_end_element_handler(void *user_data, raptor_uri* datatype_uri=NULL; char* language_str=NULL; - lvalue=(unsigned char*)RASQAL_MALLOC(cstring, con->value_len+1); + lvalue = RASQAL_MALLOC(unsigned char*, con->value_len + 1); memcpy(lvalue, con->value, con->value_len + 1); if(con->datatype) datatype_uri = raptor_new_uri(con->world->raptor_world_ptr, (const unsigned char*)con->datatype); if(con->language) { size_t language_len = strlen(con->language); - language_str=(char*)RASQAL_MALLOC(cstring, language_len + 1); + language_str = RASQAL_MALLOC(char*, language_len + 1); memcpy(language_str, con->language, language_len + 1); } l = rasqal_new_string_literal_node(con->world, lvalue, language_str, @@ -725,7 +725,7 @@ rasqal_sparql_xml_sax2_end_element_handler(void *user_data, if(1) { rasqal_literal* l; unsigned char* lvalue; - lvalue=(unsigned char*)RASQAL_MALLOC(cstring, con->value_len+1); + lvalue = RASQAL_MALLOC(unsigned char*, con->value_len + 1); memcpy(lvalue, con->value, con->value_len + 1); l = rasqal_new_simple_literal(con->world, RASQAL_LITERAL_BLANK, lvalue); rasqal_row_set_value_at(con->row, con->result_offset, l); @@ -766,7 +766,7 @@ rasqal_sparql_xml_sax2_end_element_handler(void *user_data, } if(con->value) { - RASQAL_FREE(cstring, con->value); + RASQAL_FREE(char*, con->value); con->value=NULL; } } @@ -922,7 +922,7 @@ rasqal_query_results_get_rowsource_sparql_xml(rasqal_query_results_formatter* fo { rasqal_rowsource_sparql_xml_context* con; - con=(rasqal_rowsource_sparql_xml_context*)RASQAL_CALLOC(rasqal_rowsource_sparql_xml_context, 1, sizeof(rasqal_rowsource_sparql_xml_context)); + con = RASQAL_CALLOC(rasqal_rowsource_sparql_xml_context*, 1, sizeof(*con)); if(!con) return NULL; diff --git a/src/rasqal_format_table.c b/src/rasqal_format_table.c index c1fad10c..83bd567b 100644 --- a/src/rasqal_format_table.c +++ b/src/rasqal_format_table.c @@ -99,8 +99,7 @@ rasqal_query_results_write_table_bindings(raptor_iostream *iostr, char *sep = NULL; bindings_count = rasqal_query_results_get_bindings_count(results); - widths = (size_t*)RASQAL_CALLOC(intarray, sizeof(size_t), - bindings_count + 1); + widths = RASQAL_CALLOC(size_t*, bindings_count + 1, sizeof(size_t)); if(!widths) { rc = 1; goto tidy; @@ -129,7 +128,7 @@ rasqal_query_results_write_table_bindings(raptor_iostream *iostr, while(!rasqal_query_results_finished(results)) { char **values; - values = (char**)RASQAL_CALLOC(stringarray, sizeof(char*), bindings_count + 1); + values = RASQAL_CALLOC(char**, bindings_count + 1, sizeof(char*)); if(!values) { rc = 1; goto tidy; @@ -174,7 +173,7 @@ rasqal_query_results_write_table_bindings(raptor_iostream *iostr, #define PAD " " #define PAD_LEN 1 sep_len = total_width + ((PAD_LEN+PAD_LEN) * bindings_count) + VSEP_LEN * (bindings_count + 1); - sep = (char*)RASQAL_MALLOC(cstring, sep_len + 1); + sep = RASQAL_MALLOC(char*, sep_len + 1); if(!sep) { rc = 1; goto tidy; diff --git a/src/rasqal_formula.c b/src/rasqal_formula.c index cff08300..4ff80754 100644 --- a/src/rasqal_formula.c +++ b/src/rasqal_formula.c @@ -47,7 +47,7 @@ rasqal_new_formula(rasqal_world* world) RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - f = (rasqal_formula*)RASQAL_CALLOC(rasqal_formula, 1, sizeof(*f)); + f = RASQAL_CALLOC(rasqal_formula*, 1, sizeof(*f)); if(!f) return NULL; diff --git a/src/rasqal_general.c b/src/rasqal_general.c index f676a4a5..d72fbb4b 100644 --- a/src/rasqal_general.c +++ b/src/rasqal_general.c @@ -111,7 +111,8 @@ rasqal_world* rasqal_new_world(void) { rasqal_world* world; - world = (rasqal_world*)RASQAL_CALLOC(rasqal_world, sizeof(rasqal_world), 1); + + world = RASQAL_CALLOC(rasqal_world*, sizeof(rasqal_world), 1); if(!world) return NULL; @@ -357,8 +358,7 @@ rasqal_query_language_register_factory(rasqal_world *world, { rasqal_query_language_factory *query = NULL; - query = (rasqal_query_language_factory*)RASQAL_CALLOC(rasqal_query_language_factory, 1, - sizeof(*query)); + query = RASQAL_CALLOC(rasqal_query_language_factory*, 1, sizeof(*query)); if(!query) goto tidy; @@ -628,7 +628,7 @@ rasqal_log_error_varargs(rasqal_world* world, raptor_log_level level, fputc('\n', stderr); } - RASQAL_FREE(cstring, buffer); + RASQAL_FREE(char*, buffer); } @@ -723,7 +723,7 @@ rasqal_escaped_name_to_utf8_string(const unsigned char *src, size_t len, unsigned char *endp; int n; - result=(unsigned char*)RASQAL_MALLOC(cstring, len+1); + result = RASQAL_MALLOC(unsigned char*, len + 1); if(!result) return NULL; @@ -741,7 +741,7 @@ rasqal_escaped_name_to_utf8_string(const unsigned char *src, size_t len, if(error_handler) error_handler(error_data, "UTF-8 encoding error at character %d (0x%02X) found.", c, c); /* UTF-8 encoding had an error or ended in the middle of a string */ - RASQAL_FREE(cstring, result); + RASQAL_FREE(char*, result); return NULL; } memcpy(dest, p, unichar_len); @@ -760,7 +760,7 @@ rasqal_escaped_name_to_utf8_string(const unsigned char *src, size_t len, } if(!len) { - RASQAL_FREE(cstring, result); + RASQAL_FREE(char*, result); return NULL; } @@ -778,7 +778,7 @@ rasqal_escaped_name_to_utf8_string(const unsigned char *src, size_t len, if(len < ulen) { if(error_handler) error_handler(error_data, "%c over end of line", c); - RASQAL_FREE(cstring, result); + RASQAL_FREE(char*, result); return 0; } @@ -804,7 +804,7 @@ rasqal_escaped_name_to_utf8_string(const unsigned char *src, size_t len, default: if(error_handler) error_handler(error_data, "Illegal string escape \\%c in \"%s\"", c, src); - RASQAL_FREE(cstring, result); + RASQAL_FREE(char*, result); return 0; } @@ -903,14 +903,14 @@ rasqal_world_set_default_generate_bnodeid_parameters(rasqal_world* world, if(prefix) { length = strlen(prefix); - prefix_copy = (char*)RASQAL_MALLOC(cstring, length + 1); + prefix_copy = RASQAL_MALLOC(char*, length + 1); if(!prefix_copy) return 1; memcpy(prefix_copy, prefix, length + 1); } if(world->default_generate_bnodeid_handler_prefix) - RASQAL_FREE(cstring, world->default_generate_bnodeid_handler_prefix); + RASQAL_FREE(char*, world->default_generate_bnodeid_handler_prefix); world->default_generate_bnodeid_handler_prefix = prefix_copy; world->default_generate_bnodeid_handler_prefix_length = length; @@ -978,7 +978,7 @@ rasqal_world_default_generate_bnodeid_handler(void *user_data, else length += 7; /* bnodeid */ - buffer = (unsigned char*)RASQAL_MALLOC(cstring, length); + buffer = RASQAL_MALLOC(unsigned char*, length); if(!buffer) return NULL; if(world->default_generate_bnodeid_handler_prefix) { @@ -1133,7 +1133,7 @@ rasqal_free_memory(void *ptr) void* rasqal_alloc_memory(size_t size) { - return RASQAL_MALLOC(void, size); + return RASQAL_MALLOC(void*, size); } @@ -1156,7 +1156,7 @@ rasqal_alloc_memory(size_t size) void* rasqal_calloc_memory(size_t nmemb, size_t size) { - return RASQAL_CALLOC(void, nmemb, size); + return RASQAL_CALLOC(void*, nmemb, size); } diff --git a/src/rasqal_graph.c b/src/rasqal_graph.c index d15cc11d..6b07fbf7 100644 --- a/src/rasqal_graph.c +++ b/src/rasqal_graph.c @@ -255,7 +255,7 @@ rasqal_new_graph(rasqal_world* world, raptor_uri *uri) rasqal_graph* g; rasqal_graph_factory *factory = world->graph_factory; - g = (rasqal_graph*)RASQAL_CALLOC(rasqal_graph, sizeof(rasqal_graph), 1); + g = RASQAL_CALLOC(rasqal_graph, sizeof(rasqal_graph), 1); if(!g) return NULL; g->world = world; diff --git a/src/rasqal_graph_pattern.c b/src/rasqal_graph_pattern.c index 7cc8fafa..9d18d4b3 100644 --- a/src/rasqal_graph_pattern.c +++ b/src/rasqal_graph_pattern.c @@ -62,8 +62,7 @@ rasqal_new_graph_pattern(rasqal_query* query, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(query, rasqal_query, NULL); - gp = (rasqal_graph_pattern*)RASQAL_CALLOC(rasqal_graph_pattern, 1, - sizeof(*gp)); + gp = RASQAL_CALLOC(rasqal_graph_pattern*, 1, sizeof(*gp)); if(!gp) return NULL; diff --git a/src/rasqal_internal.h b/src/rasqal_internal.h index cec8219c..ee4a0689 100644 --- a/src/rasqal_internal.h +++ b/src/rasqal_internal.h @@ -64,14 +64,14 @@ void* rasqal_sign_calloc(size_t nmemb, size_t size); void* rasqal_sign_realloc(void *ptr, size_t size); void rasqal_sign_free(void *ptr); -#define RASQAL_MALLOC(type, size) rasqal_sign_malloc(size) -#define RASQAL_CALLOC(type, nmemb, size) rasqal_sign_calloc(nmemb, size) -#define RASQAL_REALLOC(type, ptr, size) rasqal_sign_realloc(ptr, size) -#define RASQAL_FREE(type, ptr) rasqal_sign_free(ptr) +#define RASQAL_MALLOC(type, size) (type)rasqal_sign_malloc(size) +#define RASQAL_CALLOC(type, nmemb, size) (type)rasqal_sign_calloc(nmemb, size) +#define RASQAL_REALLOC(type, ptr, size) (type0rasqal_sign_realloc(ptr, size) +#define RASQAL_FREE(type, ptr) rasqal_sign_free((void*)ptr) #else -#define RASQAL_MALLOC(type, size) malloc(size) -#define RASQAL_CALLOC(type, size, count) calloc(size, count) +#define RASQAL_MALLOC(type, size) (type)malloc(size) +#define RASQAL_CALLOC(type, size, count) (type)calloc(size, count) #define RASQAL_FREE(type, ptr) free((void*)ptr) #endif @@ -482,7 +482,7 @@ struct rasqal_query_s { * is the name used for constructing a rasqal_query_formatter * from the results. */ - const char* query_results_formatter_name; + char* query_results_formatter_name; /* flag: non-0 if EXPLAIN was given */ int explain; diff --git a/src/rasqal_literal.c b/src/rasqal_literal.c index 4090d8ab..9a0d1155 100644 --- a/src/rasqal_literal.c +++ b/src/rasqal_literal.c @@ -97,7 +97,7 @@ rasqal_new_integer_literal(rasqal_world* world, rasqal_literal_type type, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -191,7 +191,7 @@ rasqal_new_typed_literal(rasqal_world* world, rasqal_literal_type type, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(!l) return NULL; @@ -231,7 +231,7 @@ rasqal_new_double_literal(rasqal_world* world, double d) RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -271,7 +271,7 @@ rasqal_new_float_literal(rasqal_world *world, float f) RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -313,7 +313,7 @@ rasqal_new_uri_literal(rasqal_world* world, raptor_uri *uri) RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -352,7 +352,7 @@ rasqal_new_pattern_literal(rasqal_world* world, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(pattern, char*, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -363,8 +363,8 @@ rasqal_new_pattern_literal(rasqal_world* world, l->flags = (const unsigned char*)flags; } else { if(flags) - RASQAL_FREE(cstring, (void*)flags); - RASQAL_FREE(cstring, (void*)pattern); + RASQAL_FREE(char*, flags); + RASQAL_FREE(char*, pattern); } return l; } @@ -410,7 +410,7 @@ rasqal_new_decimal_literal_from_decimal(rasqal_world* world, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); /* string and decimal NULLness are checked below */ - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(!l) return NULL; @@ -532,7 +532,7 @@ rasqal_new_datetime_literal_from_datetime(rasqal_world* world, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(dt, rasqal_xsd_datetime, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(!l) goto failed; @@ -611,16 +611,16 @@ rasqal_literal_set_typed_value(rasqal_literal* l, rasqal_literal_type type, } if(l->language) { - RASQAL_FREE(cstring, (void*)l->language); + RASQAL_FREE(char*, l->language); l->language = NULL; } l->type = type; if(string) { if(l->string) - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); l->string_len = (unsigned int)strlen((const char*)string); - l->string = (unsigned char*)RASQAL_MALLOC(cstring, l->string_len+1); + l->string = RASQAL_MALLOC(unsigned char*, l->string_len + 1); if(!l->string) return 1; memcpy((void*)l->string, string, l->string_len + 1); @@ -674,16 +674,16 @@ rasqal_literal_set_typed_value(rasqal_literal* l, rasqal_literal_type type, l->value.decimal = rasqal_new_xsd_decimal(l->world); if(!l->value.decimal) { /* free l->string which is not owned by literal yet */ - RASQAL_FREE(cstring, (void*)l->string); l->string = NULL; + RASQAL_FREE(char*, l->string); l->string = NULL; return 1; } if(rasqal_xsd_decimal_set_string(l->value.decimal, (const char*)l->string)) { /* free l->string which is not owned by literal yet */ - RASQAL_FREE(cstring, (void*)l->string); l->string = NULL; + RASQAL_FREE(char*, l->string); l->string = NULL; return 1; } - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); /* l->string is now owned by l->value.decimal and will be freed * on literal destruction @@ -702,7 +702,7 @@ rasqal_literal_set_typed_value(rasqal_literal* l, rasqal_literal_type type, case RASQAL_LITERAL_BOOLEAN: i = rasqal_literal_string_interpreted_as_boolean(l->string); /* Free passed in string */ - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); /* and replace with a static string */ l->string = i ? RASQAL_XSD_BOOLEAN_TRUE : RASQAL_XSD_BOOLEAN_FALSE; l->string_len = i ? RASQAL_XSD_BOOLEAN_TRUE_LEN : RASQAL_XSD_BOOLEAN_FALSE_LEN; @@ -718,10 +718,10 @@ rasqal_literal_set_typed_value(rasqal_literal* l, rasqal_literal_type type, l->value.datetime = rasqal_new_xsd_datetime(l->world, (const char*)l->string); if(!l->value.datetime) { - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); return 1; } - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); l->string = (unsigned char*)rasqal_xsd_datetime_to_counted_string(l->value.datetime, (size_t*)&l->string_len); if(!l->string) @@ -840,7 +840,7 @@ rasqal_new_string_literal_common(rasqal_world* world, { rasqal_literal* l; - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { rasqal_literal_type datatype_type = RASQAL_LITERAL_STRING; @@ -850,7 +850,7 @@ rasqal_new_string_literal_common(rasqal_world* world, if(datatype && language) { /* RDF typed literal but this is not allowed so delete language */ - RASQAL_FREE(cstring, (void*)language); + RASQAL_FREE(char*, language); language = NULL; } @@ -871,12 +871,12 @@ rasqal_new_string_literal_common(rasqal_world* world, } } else { if(language) - RASQAL_FREE(cstring, (void*)language); + RASQAL_FREE(char*, language); if(datatype) raptor_free_uri(datatype); if(datatype_qname) - RASQAL_FREE(cstring, (void*)datatype_qname); - RASQAL_FREE(cstring, (void*)string); + RASQAL_FREE(char*, datatype_qname); + RASQAL_FREE(char*, string); } return l; @@ -955,7 +955,7 @@ rasqal_new_simple_literal(rasqal_world* world, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(string, char*, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -964,7 +964,7 @@ rasqal_new_simple_literal(rasqal_world* world, l->string = string; l->string_len = (unsigned int)strlen((const char*)string); } else { - RASQAL_FREE(cstring, (void*)string); + RASQAL_FREE(char*, string); } return l; } @@ -987,7 +987,7 @@ rasqal_new_boolean_literal(rasqal_world* world, int value) RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -1026,7 +1026,7 @@ rasqal_new_variable_literal(rasqal_world* world, rasqal_variable *variable) RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(variable, rasqal_variable, NULL); - l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*l)); + l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*l)); if(l) { l->valid = 1; l->usage = 1; @@ -1091,20 +1091,20 @@ rasqal_free_literal(rasqal_literal* l) case RASQAL_LITERAL_UDT: case RASQAL_LITERAL_INTEGER_SUBTYPE: if(l->string) - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); if(l->language) - RASQAL_FREE(cstring, (void*)l->language); + RASQAL_FREE(char*, l->language); if(l->datatype) raptor_free_uri(l->datatype); if(l->type == RASQAL_LITERAL_STRING || l->type == RASQAL_LITERAL_PATTERN) { if(l->flags) - RASQAL_FREE(cstring, (void*)l->flags); + RASQAL_FREE(char*, l->flags); } break; case RASQAL_LITERAL_DATETIME: if(l->string) - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); if(l->datatype) raptor_free_uri(l->datatype); if(l->value.datetime) @@ -1965,7 +1965,7 @@ rasqal_new_literal_from_promotion(rasqal_literal* lit, float f; int i; unsigned char *new_s = NULL; - const unsigned char* s; + unsigned char* s; size_t len; rasqal_xsd_decimal* dec = NULL; @@ -1984,8 +1984,8 @@ rasqal_new_literal_from_promotion(rasqal_literal* lit, rasqal_literal_type_label(lit->type)); if(type == RASQAL_LITERAL_STRING || type == RASQAL_LITERAL_UDT) { - s = rasqal_literal_as_counted_string(lit, &len, 0, NULL); - new_s = (unsigned char*)RASQAL_MALLOC(sstring, len+1); + s = (unsigned char*)rasqal_literal_as_counted_string(lit, &len, 0, NULL); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(new_s) { raptor_uri* dt_uri = NULL; memcpy(new_s, s, len + 1); @@ -2057,8 +2057,8 @@ rasqal_new_literal_from_promotion(rasqal_literal* lit, break; case RASQAL_LITERAL_STRING: - s = rasqal_literal_as_counted_string(lit, &len, 0, NULL); - new_s = (unsigned char*)RASQAL_MALLOC(sstring, len + 1); + s = (unsigned char*)rasqal_literal_as_counted_string(lit, &len, 0, NULL); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(new_s) { memcpy(new_s, s, len + 1); new_lit = rasqal_new_string_literal(lit->world, new_s, NULL, NULL, NULL); @@ -2066,8 +2066,8 @@ rasqal_new_literal_from_promotion(rasqal_literal* lit, break; case RASQAL_LITERAL_XSD_STRING: - s = rasqal_literal_as_counted_string(lit, &len, 0, NULL); - new_s = (unsigned char*)RASQAL_MALLOC(sstring, len + 1); + s = (unsigned char*)rasqal_literal_as_counted_string(lit, &len, 0, NULL); + new_s = RASQAL_MALLOC(unsigned char*, len + 1); if(new_s) { raptor_uri* dt_uri; memcpy(new_s, s, len + 1); @@ -2814,7 +2814,7 @@ rasqal_literal_expand_qname(void *user_data, rasqal_literal *l) l->string, l->string_len); if(!uri) return 1; - RASQAL_FREE(cstring, (void*)l->string); + RASQAL_FREE(char*, l->string); l->string = NULL; l->type = RASQAL_LITERAL_URI; l->value.uri = uri; @@ -2829,11 +2829,11 @@ rasqal_literal_expand_qname(void *user_data, rasqal_literal *l) if(!uri) return 1; l->datatype = uri; - RASQAL_FREE(cstring, (void*)l->flags); + RASQAL_FREE(char*, l->flags); l->flags = NULL; if(l->language && uri) { - RASQAL_FREE(cstring, (void*)l->language); + RASQAL_FREE(char*, l->language); l->language = NULL; } @@ -2906,14 +2906,14 @@ rasqal_literal_as_node(rasqal_literal* l) case RASQAL_LITERAL_DATETIME: case RASQAL_LITERAL_UDT: case RASQAL_LITERAL_INTEGER_SUBTYPE: - new_l = (rasqal_literal*)RASQAL_CALLOC(rasqal_literal, 1, sizeof(*new_l)); + new_l = RASQAL_CALLOC(rasqal_literal*, 1, sizeof(*new_l)); if(new_l) { new_l->valid = 1; new_l->usage = 1; new_l->world = l->world; new_l->type = RASQAL_LITERAL_STRING; new_l->string_len = l->string_len; - new_l->string = (unsigned char*)RASQAL_MALLOC(cstring, l->string_len+1); + new_l->string = RASQAL_MALLOC(unsigned char*, l->string_len + 1); if(!new_l->string) { rasqal_free_literal(new_l); return NULL; @@ -3183,7 +3183,7 @@ rasqal_literal_cast(rasqal_literal* l, raptor_uri* to_datatype, int flags, return NULL; } - new_string = (unsigned char*)RASQAL_MALLOC(string, len + 1); + new_string = RASQAL_MALLOC(unsigned char*, len + 1); if(!new_string) { *error_p = 1; return NULL; @@ -4414,8 +4414,7 @@ rasqal_new_literal_sequence_sort_map(int is_distinct, int compare_flags) { literal_sequence_sort_compare_data* lsscd; - lsscd = (literal_sequence_sort_compare_data*)RASQAL_MALLOC(literal_sequence_sort_compare_data, - sizeof(*lsscd)); + lsscd = RASQAL_MALLOC(literal_sequence_sort_compare_data*, sizeof(*lsscd)); if(!lsscd) return NULL; @@ -4537,7 +4536,7 @@ rasqal_new_literal_sequence_of_sequence_from_data(rasqal_world* world, number); } else { unsigned char *val; - val = (unsigned char*)RASQAL_MALLOC(cstring, str_len+1); + val = RASQAL_MALLOC(unsigned char*, str_len + 1); if(val) { memcpy(val, str, str_len + 1); diff --git a/src/rasqal_map.c b/src/rasqal_map.c index 7ecd9c0d..fa675872 100644 --- a/src/rasqal_map.c +++ b/src/rasqal_map.c @@ -70,7 +70,7 @@ rasqal_new_map_node(rasqal_map* map, void *key, void *value) { rasqal_map_node *node; - node = (rasqal_map_node*)RASQAL_CALLOC(rasqal_map_node, 1, sizeof(*node)); + node = RASQAL_CALLOC(rasqal_map_node*, 1, sizeof(*node)); if(!node) return NULL; @@ -129,7 +129,7 @@ rasqal_new_map(rasqal_compare_fn* compare_fn, { rasqal_map *map; - map = (rasqal_map*)RASQAL_CALLOC(rasqal_map, 1, sizeof(rasqal_map)); + map = RASQAL_CALLOC(rasqal_map*, 1, sizeof(*map)); if(!map) { if(free_compare_data_fn) free_compare_data_fn(compare_user_data); diff --git a/src/rasqal_prefix.c b/src/rasqal_prefix.c index 9f967296..4ea18c83 100644 --- a/src/rasqal_prefix.c +++ b/src/rasqal_prefix.c @@ -61,13 +61,13 @@ rasqal_new_prefix(rasqal_world* world, const unsigned char *prefix, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(uri, raptor_uri, NULL); - p = (rasqal_prefix*)RASQAL_CALLOC(rasqal_prefix, 1, sizeof(*p)); + p = RASQAL_CALLOC(rasqal_prefix*, 1, sizeof(*p)); if(p) { p->world = world; p->prefix = prefix; p->uri = uri; } else { - RASQAL_FREE(cstring, prefix); + RASQAL_FREE(char*, prefix); raptor_free_uri(uri); } @@ -88,7 +88,7 @@ rasqal_free_prefix(rasqal_prefix* p) return; if(p->prefix) - RASQAL_FREE(cstring, (void*)p->prefix); + RASQAL_FREE(char*, p->prefix); if(p->uri) raptor_free_uri(p->uri); RASQAL_FREE(rasqal_prefix, p); diff --git a/src/rasqal_projection.c b/src/rasqal_projection.c index 35ec8bb4..fe509880 100644 --- a/src/rasqal_projection.c +++ b/src/rasqal_projection.c @@ -60,8 +60,7 @@ rasqal_new_projection(rasqal_query* query, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(query, rasqal_query, NULL); - projection = (rasqal_projection*)RASQAL_CALLOC(rasqal_projection, - 1, sizeof(*projection)); + projection = RASQAL_CALLOC(rasqal_projection*, 1, sizeof(*projection)); if(!projection) return NULL; diff --git a/src/rasqal_query.c b/src/rasqal_query.c index e74d8cbe..085a3843 100644 --- a/src/rasqal_query.c +++ b/src/rasqal_query.c @@ -107,7 +107,7 @@ rasqal_new_query(rasqal_world *world, const char *name, if(!factory) return NULL; - query = (rasqal_query*)RASQAL_CALLOC(rasqal_query, 1, sizeof(rasqal_query)); + query = RASQAL_CALLOC(rasqal_query*, 1, sizeof(*query)); if(!query) return NULL; @@ -120,8 +120,7 @@ rasqal_new_query(rasqal_world *world, const char *name, query->genid_counter = 1; - query->context = (char*)RASQAL_CALLOC(rasqal_query_context, 1, - factory->context_length); + query->context = RASQAL_CALLOC(void*, 1, factory->context_length); if(!query->context) goto tidy; @@ -198,7 +197,7 @@ rasqal_free_query(rasqal_query* query) raptor_free_uri(query->base_uri); if(query->query_string) - RASQAL_FREE(cstring, query->query_string); + RASQAL_FREE(char*, query->query_string); if(query->data_graphs) raptor_free_sequence(query->data_graphs); @@ -231,7 +230,7 @@ rasqal_free_query(rasqal_query* query) raptor_free_sequence(query->graph_patterns_sequence); if(query->query_results_formatter_name) - RASQAL_FREE(cstring, query->query_results_formatter_name); + RASQAL_FREE(char*, query->query_results_formatter_name); /* Do this last since most everything above could refer to a variable */ if(query->vars_table) @@ -1191,7 +1190,7 @@ rasqal_query_prepare(rasqal_query* query, * `base[size-2]', inclusive. */ size_t len = strlen((const char*)query_string)+3; /* +3 for " \0\0" */ - unsigned char *query_string_copy = (unsigned char*)RASQAL_MALLOC(cstring, len); + unsigned char *query_string_copy = RASQAL_MALLOC(unsigned char*, len); if(!query_string_copy) { query->failed = 1; return 1; @@ -1872,7 +1871,7 @@ rasqal_query_get_genid(rasqal_query* query, const unsigned char* base, while(tmpcounter /= 10) length++; - buffer = (unsigned char*)RASQAL_MALLOC(cstring, length); + buffer = RASQAL_MALLOC(unsigned char*, length); if(!buffer) return NULL; diff --git a/src/rasqal_query_results.c b/src/rasqal_query_results.c index a6f10fd6..1392e199 100644 --- a/src/rasqal_query_results.c +++ b/src/rasqal_query_results.c @@ -201,8 +201,7 @@ rasqal_new_query_results(rasqal_world* world, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(vars_table, rasqal_variables_table, NULL); - query_results = (rasqal_query_results*)RASQAL_CALLOC(rasqal_query_results, - 1, sizeof(*query_results)); + query_results = RASQAL_CALLOC(rasqal_query_results*, 1, sizeof(*query_results)); if(!query_results) return NULL; @@ -270,7 +269,7 @@ rasqal_query_results_execute_with_engine(rasqal_query_results* query_results, ex_data_size = query_results->execution_factory->execution_data_size; if(ex_data_size > 0) { - query_results->execution_data = RASQAL_CALLOC(data, 1, ex_data_size); + query_results->execution_data = RASQAL_CALLOC(void*, 1, ex_data_size); if(!query_results->execution_data) return 1; @@ -1027,7 +1026,7 @@ rasqal_prefix_id(int prefix_id, unsigned char *string) while(tmpid /= 10) length++; - buffer = (unsigned char*)RASQAL_MALLOC(cstring, length); + buffer = RASQAL_MALLOC(unsigned char*, length); if(!buffer) return NULL; diff --git a/src/rasqal_query_test.c b/src/rasqal_query_test.c index a9b2063e..d2e382ab 100644 --- a/src/rasqal_query_test.c +++ b/src/rasqal_query_test.c @@ -106,7 +106,7 @@ main(int argc, char **argv) { } data_string = raptor_uri_filename_to_uri_string(data_file); - query_string=(unsigned char*)RASQAL_MALLOC(cstring, strlen((const char*)data_string)+strlen(query_format)+1); + query_string = RASQAL_MALLOC(unsigned char*, strlen((const char*)data_string) + strlen(query_format) + 1); sprintf((char*)query_string, query_format, data_string); raptor_free_memory(data_string); @@ -128,7 +128,7 @@ main(int argc, char **argv) { return(1); } - RASQAL_FREE(cstring, query_string); + RASQAL_FREE(char*, query_string); printf("%s: executing query #1\n", program); results=rasqal_query_execute(query); diff --git a/src/rasqal_query_transform.c b/src/rasqal_query_transform.c index be52d416..91a4ae90 100644 --- a/src/rasqal_query_transform.c +++ b/src/rasqal_query_transform.c @@ -382,8 +382,7 @@ rasqal_query_build_variable_agg_use(rasqal_query* query) width = rasqal_variables_table_get_total_variables_count(query->vars_table); height = RASQAL_VAR_USE_MAP_OFFSET_LAST + 1 + query->graph_pattern_count; - agg_row = (unsigned short*)RASQAL_CALLOC(intarray, width, - sizeof(unsigned short)); + agg_row = RASQAL_CALLOC(unsigned short*, width, sizeof(unsigned short)); if(!agg_row) return NULL; @@ -1814,8 +1813,7 @@ rasqal_query_build_variables_use_map_binds(rasqal_query* query, int rc; unsigned short* vars_scope; - vars_scope = (unsigned short*)RASQAL_CALLOC(intarray, width, - sizeof(unsigned short)); + vars_scope = RASQAL_CALLOC(unsigned short*,width, sizeof(unsigned short)); if(!vars_scope) return 1; @@ -2097,8 +2095,8 @@ rasqal_query_build_variables_use_map(rasqal_query* query) width = rasqal_variables_table_get_total_variables_count(query->vars_table); height = RASQAL_VAR_USE_MAP_OFFSET_LAST + 1 + query->graph_pattern_count; - use_map = (unsigned short*)RASQAL_CALLOC(shortarray, width * height, - sizeof(unsigned short)); + use_map = RASQAL_CALLOC(unsigned short*, width * height, + sizeof(unsigned short)); if(!use_map) return 1; @@ -2108,8 +2106,8 @@ rasqal_query_build_variables_use_map(rasqal_query* query) query->variables_use_map = use_map; height = raptor_sequence_size(query->triples); - use_map = (unsigned short*)RASQAL_CALLOC(shortarray, width * height, - sizeof(unsigned short)); + use_map = RASQAL_CALLOC(unsigned short*, width * height, + sizeof(unsigned short)); if(!use_map) { RASQAL_FREE(shortarray, query->variables_use_map); query->variables_use_map = NULL; @@ -2401,8 +2399,8 @@ rasqal_query_select_build_variables_use_map_binds(rasqal_query* query, int size; int i; - inner_vars_scope = (unsigned short*)RASQAL_CALLOC(intarray, width, - sizeof(unsigned short)); + inner_vars_scope = RASQAL_CALLOC(unsigned short*,width, + sizeof(unsigned short)); if(!inner_vars_scope) return 1; @@ -2465,8 +2463,8 @@ rasqal_query_union_build_variables_use_map_binds(rasqal_query* query, seq = gp->graph_patterns; gp_size = raptor_sequence_size(seq); - inner_vars_scope = (unsigned short*)RASQAL_CALLOC(intarray, width, - sizeof(unsigned short)); + inner_vars_scope = RASQAL_CALLOC(unsigned short*, width, + sizeof(unsigned short)); if(!inner_vars_scope) return 1; diff --git a/src/rasqal_raptor.c b/src/rasqal_raptor.c index 3bb61d9e..ed258ff6 100644 --- a/src/rasqal_raptor.c +++ b/src/rasqal_raptor.c @@ -93,7 +93,7 @@ raptor_statement_as_rasqal_triple(rasqal_world* world, /* subject */ if(statement->subject->type == RAPTOR_TERM_TYPE_BLANK) { len = statement->subject->value.blank.string_len; - new_str = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_str = RASQAL_MALLOC(unsigned char*, len + 1); memcpy(new_str, statement->subject->value.blank.string, len + 1); s = rasqal_new_simple_literal(world, RASQAL_LITERAL_BLANK, new_str); } else { @@ -110,12 +110,12 @@ raptor_statement_as_rasqal_triple(rasqal_world* world, char *language = NULL; len = statement->object->value.literal.string_len; - new_str = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_str = RASQAL_MALLOC(unsigned char*, len + 1); memcpy(new_str, statement->object->value.literal.string, len + 1); if(statement->object->value.literal.language) { len = statement->object->value.literal.language_len; - language = (char*)RASQAL_MALLOC(cstring, len + 1); + language = RASQAL_MALLOC(char*, len + 1); memcpy(language, statement->object->value.literal.language, len + 1); } @@ -127,7 +127,7 @@ raptor_statement_as_rasqal_triple(rasqal_world* world, o = rasqal_new_string_literal(world, new_str, language, uri, NULL); } else if(statement->object->type == RAPTOR_TERM_TYPE_BLANK) { len = statement->object->value.blank.string_len; - new_str = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + new_str = RASQAL_MALLOC(unsigned char*, len + 1); memcpy(new_str, statement->object->value.blank.string, len + 1); o = rasqal_new_simple_literal(world, RASQAL_LITERAL_BLANK, new_str); } else { @@ -148,8 +148,7 @@ rasqal_raptor_statement_handler(void *user_data, rtsc = (rasqal_raptor_triples_source_user_data*)user_data; - triple = (rasqal_raptor_triple*)RASQAL_MALLOC(rasqal_raptor_triple, - sizeof(rasqal_raptor_triple)); + triple = RASQAL_MALLOC(rasqal_raptor_triple*, sizeof(rasqal_raptor_triple)); triple->next = NULL; triple->triple = raptor_statement_as_rasqal_triple(rtsc->query->world, statement); @@ -181,9 +180,8 @@ rasqal_raptor_generate_id_handler(void *user_data, unsigned char *mapped_id; size_t user_bnodeid_len = strlen((const char*)user_bnodeid); - mapped_id = (unsigned char*)RASQAL_MALLOC(cstring, - rtsc->mapped_id_base_len + 1 + - user_bnodeid_len + 1); + mapped_id = RASQAL_MALLOC(unsigned char*, + rtsc->mapped_id_base_len + 1 + user_bnodeid_len + 1); memcpy(mapped_id, rtsc->mapped_id_base, rtsc->mapped_id_base_len); mapped_id[rtsc->mapped_id_base_len] = '_'; memcpy(mapped_id + rtsc->mapped_id_base_len + 1, @@ -241,9 +239,8 @@ rasqal_raptor_init_triples_source(rasqal_query* rdf_query, rtsc->sources_count = 0; if(rtsc->sources_count) - rtsc->source_literals = (rasqal_literal**)RASQAL_CALLOC(rasqal_literal_ptr, - rtsc->sources_count, - sizeof(rasqal_literal*)); + rtsc->source_literals = RASQAL_CALLOC(rasqal_literal**, rtsc->sources_count, + sizeof(rasqal_literal*)); else rtsc->source_literals = NULL; @@ -319,7 +316,7 @@ rasqal_raptor_init_triples_source(rasqal_query* rdf_query, /* This is freed in rasqal_raptor_free_triples_source() */ /* rasqal_free_literal(rtsc->source_literal); */ - RASQAL_FREE(cstring, rtsc->mapped_id_base); + RASQAL_FREE(char*, rtsc->mapped_id_base); if(rdf_query->failed) { rasqal_raptor_free_triples_source(user_data); @@ -664,7 +661,7 @@ rasqal_raptor_init_triples_match(rasqal_triples_match* rtm, rtm->is_end = rasqal_raptor_is_end; rtm->finish = rasqal_raptor_finish_triples_match; - rtmc = (rasqal_raptor_triples_match_context*)RASQAL_CALLOC(rasqal_raptor_triples_match_context, 1, sizeof(rasqal_raptor_triples_match_context)); + rtmc = RASQAL_CALLOC(rasqal_raptor_triples_match_context*, 1, sizeof(*rtmc)); if(!rtmc) return -1; diff --git a/src/rasqal_result_formats.c b/src/rasqal_result_formats.c index 6fc8de9c..2f3b677f 100644 --- a/src/rasqal_result_formats.c +++ b/src/rasqal_result_formats.c @@ -61,8 +61,8 @@ rasqal_world_register_query_results_format_factory(rasqal_world* world, { rasqal_query_results_format_factory *factory = NULL; - factory = (rasqal_query_results_format_factory*)RASQAL_CALLOC(rasqal_query_factory_factory, 1, - sizeof(*factory)); + factory = RASQAL_CALLOC(rasqal_query_results_format_factory*, 1, + sizeof(*factory)); if(!factory) return NULL; @@ -287,7 +287,7 @@ rasqal_new_query_results_formatter(rasqal_world* world, if(!factory) return NULL; - formatter = (rasqal_query_results_formatter*)RASQAL_CALLOC(rasqal_query_results_formatter, 1, sizeof(*formatter)); + formatter = RASQAL_CALLOC(rasqal_query_results_formatter*, 1, sizeof(*formatter)); if(!formatter) return NULL; @@ -295,8 +295,7 @@ rasqal_new_query_results_formatter(rasqal_world* world, formatter->context = NULL; if(factory->context_length) { - formatter->context = (char*)RASQAL_CALLOC(rasqal_query_results_formatter_context, 1, - factory->context_length); + formatter->context = RASQAL_CALLOC(void*, 1, factory->context_length); if(!formatter->context) { rasqal_free_query_results_formatter(formatter); return NULL; @@ -537,9 +536,9 @@ rasqal_world_guess_query_results_format_name(rasqal_world* world, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); - scores = (struct syntax_score*)RASQAL_CALLOC(syntax_scores, - raptor_sequence_size(world->query_results_formats), - sizeof(struct syntax_score)); + scores = RASQAL_CALLOC(struct syntax_score*, + raptor_sequence_size(world->query_results_formats), + sizeof(struct syntax_score)); if(!scores) return NULL; @@ -549,8 +548,7 @@ rasqal_world_guess_query_results_format_name(rasqal_world* world, unsigned char *from, *to; p++; - suffix = (unsigned char*)RASQAL_MALLOC(cstring, - strlen((const char*)p) + 1); + suffix = RASQAL_MALLOC(unsigned char*, strlen((const char*)p) + 1); if(!suffix) return NULL; @@ -558,7 +556,7 @@ rasqal_world_guess_query_results_format_name(rasqal_world* world, unsigned char c = *from++; /* discard the suffix if it wasn't '\.[a-zA-Z0-9]+$' */ if(!isalpha(c) && !isdigit(c)) { - RASQAL_FREE(cstring, suffix); + RASQAL_FREE(char*, suffix); suffix = NULL; to = NULL; break; @@ -642,7 +640,7 @@ rasqal_world_guess_query_results_format_name(rasqal_world* world, } if(suffix) - RASQAL_FREE(cstring, suffix); + RASQAL_FREE(char*, suffix); RASQAL_FREE(syntax_scores, scores); diff --git a/src/rasqal_row.c b/src/rasqal_row.c index 19975d66..0fb82ef0 100644 --- a/src/rasqal_row.c +++ b/src/rasqal_row.c @@ -48,7 +48,7 @@ rasqal_new_row_common(rasqal_world* world, int size, int order_size) { rasqal_row* row; - row = (rasqal_row*)RASQAL_CALLOC(rasqal_row, 1, sizeof(rasqal_row)); + row = RASQAL_CALLOC(rasqal_row*, 1, sizeof(*row)); if(!row) return NULL; @@ -56,16 +56,16 @@ rasqal_new_row_common(rasqal_world* world, int size, int order_size) row->size = size; row->order_size = order_size; - row->values = (rasqal_literal**)RASQAL_CALLOC(array, row->size, - sizeof(rasqal_literal*)); + row->values = RASQAL_CALLOC(rasqal_literal**, row->size, + sizeof(rasqal_literal*)); if(!row->values) { rasqal_free_row(row); return NULL; } if(row->order_size > 0) { - row->order_values = (rasqal_literal**)RASQAL_CALLOC(array, row->order_size, - sizeof(rasqal_literal*)); + row->order_values = RASQAL_CALLOC(rasqal_literal**,row->order_size, + sizeof(rasqal_literal*)); if(!row->order_values) { rasqal_free_row(row); return NULL; @@ -330,7 +330,7 @@ rasqal_new_row_sequence(rasqal_world* world, const unsigned char* name; rasqal_variable* v; - name = (unsigned char*)RASQAL_MALLOC(cstring, var_name_len+1); + name = RASQAL_MALLOC(unsigned char*, var_name_len + 1); if(!name) { failed = 1; goto tidy; @@ -387,7 +387,7 @@ rasqal_new_row_sequence(rasqal_world* world, number); } else { unsigned char *val; - val = (unsigned char*)RASQAL_MALLOC(cstring, str_len + 1); + val = RASQAL_MALLOC(unsigned char*, str_len + 1); if(val) { memcpy(val, str, str_len + 1); @@ -515,7 +515,7 @@ rasqal_row_set_order_size(rasqal_row *row, int order_size) { row->order_size = order_size; if(row->order_size > 0) { - row->order_values = (rasqal_literal**)RASQAL_CALLOC(array, row->order_size, + row->order_values = RASQAL_CALLOC(rasqal_literal**, row->order_size, sizeof(rasqal_literal*)); if(!row->order_values) { row->order_size = -1; @@ -545,8 +545,7 @@ rasqal_row_expand_size(rasqal_row *row, int size) if(row->size > size) return 1; - nvalues = (rasqal_literal**)RASQAL_CALLOC(array, size, - sizeof(rasqal_literal*)); + nvalues = RASQAL_CALLOC(rasqal_literal**, size, sizeof(rasqal_literal*)); if(!nvalues) return 1; memcpy(nvalues, row->values, sizeof(rasqal_literal*) * row->size); diff --git a/src/rasqal_row_compatible.c b/src/rasqal_row_compatible.c index d39ad5a2..6841bcdc 100644 --- a/src/rasqal_row_compatible.c +++ b/src/rasqal_row_compatible.c @@ -48,14 +48,14 @@ rasqal_new_row_compatible(rasqal_variables_table* vt, int count = rasqal_variables_table_get_total_variables_count(vt); int i; - map = (rasqal_row_compatible*)RASQAL_CALLOC(rasqal_row_compatible, 1, sizeof(rasqal_row_compatible)); + map = RASQAL_CALLOC(rasqal_row_compatible*, 1, sizeof(*map)); if(!map) return NULL; map->variables_table = vt; map->first_rowsource = first_rowsource; map->second_rowsource = second_rowsource; map->variables_count = count; - map->defined_in_map = (int*)RASQAL_CALLOC(intarray, 2*count, sizeof(int)); + map->defined_in_map = RASQAL_CALLOC(int*, 2 * count, sizeof(int)); if(!map->defined_in_map) { RASQAL_FREE(rasqal_row_compatible, map); return NULL; diff --git a/src/rasqal_rowsource.c b/src/rasqal_rowsource.c index 840b4b8d..6ded5fe9 100644 --- a/src/rasqal_rowsource.c +++ b/src/rasqal_rowsource.c @@ -74,8 +74,7 @@ rasqal_new_rowsource_from_handler(rasqal_world* world, if(handler->version < 1 || handler->version > 1) return NULL; - rowsource = (rasqal_rowsource*)RASQAL_CALLOC(rasqal_rowsource, 1, - sizeof(rasqal_rowsource)); + rowsource = RASQAL_CALLOC(rasqal_rowsource*, 1, sizeof(*rowsource)); if(!rowsource) { if(handler->finish) handler->finish(NULL, user_data); diff --git a/src/rasqal_rowsource_aggregation.c b/src/rasqal_rowsource_aggregation.c index abfcad83..1dfed41b 100644 --- a/src/rasqal_rowsource_aggregation.c +++ b/src/rasqal_rowsource_aggregation.c @@ -172,8 +172,7 @@ rasqal_builtin_agg_expression_execute_init(rasqal_world *world, { rasqal_builtin_agg_expression_execute* b; - b = (rasqal_builtin_agg_expression_execute*)RASQAL_CALLOC(rasqal_builtin_agg_expression_execute, - sizeof(*b), 1); + b = RASQAL_CALLOC(rasqal_builtin_agg_expression_execute*, 1, sizeof(*b)); if(!b) return NULL; @@ -361,12 +360,12 @@ rasqal_builtin_agg_expression_execute_result(void* user_data) rasqal_literal* result; len = raptor_stringbuffer_length(b->sb); - str = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + str = RASQAL_MALLOC(unsigned char*, len + 1); if(!str) return NULL; if(raptor_stringbuffer_copy_to_string(b->sb, str, len)) { - RASQAL_FREE(cstring, str); + RASQAL_FREE(char*, str); return NULL; } @@ -843,7 +842,7 @@ rasqal_new_aggregation_rowsource(rasqal_world *world, rasqal_query* query, } - con = (rasqal_aggregation_rowsource_context*)RASQAL_CALLOC(rasqal_aggregation_rowsource_context, 1, sizeof(*con)); + con = RASQAL_CALLOC(rasqal_aggregation_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; @@ -854,9 +853,8 @@ rasqal_new_aggregation_rowsource(rasqal_world *world, rasqal_query* query, /* allocate per-expr data */ con->expr_count = size; - con->expr_data = (rasqal_agg_expr_data*)RASQAL_CALLOC(rasqal_agg_expr_data, - sizeof(rasqal_agg_expr_data), - size); + con->expr_data = RASQAL_CALLOC(rasqal_agg_expr_data*, size, + sizeof(rasqal_agg_expr_data)); if(!con->expr_data) goto fail; @@ -1161,7 +1159,7 @@ main(int argc, char *argv[]) } /* if vars */ - output_var_name = (char*)RASQAL_MALLOC(cstring, 5); + output_var_name = RASQAL_MALLOC(char*, 5); memcpy(output_var_name, "fake", 5); output_var = rasqal_variables_table_add(vt, RASQAL_VARIABLE_TYPE_ANONYMOUS, (const unsigned char*)output_var_name, NULL); diff --git a/src/rasqal_rowsource_assignment.c b/src/rasqal_rowsource_assignment.c index b20bdd83..0963d582 100644 --- a/src/rasqal_rowsource_assignment.c +++ b/src/rasqal_rowsource_assignment.c @@ -198,7 +198,7 @@ rasqal_new_assignment_rowsource(rasqal_world *world, if(!world || !query || !var || !expr) return NULL; - con = (rasqal_assignment_rowsource_context*)RASQAL_CALLOC(rasqal_assignment_rowsource_context, 1, sizeof(rasqal_assignment_rowsource_context)); + con = RASQAL_CALLOC(rasqal_assignment_rowsource_context*, 1, sizeof(*con)); if(!con) return NULL; diff --git a/src/rasqal_rowsource_distinct.c b/src/rasqal_rowsource_distinct.c index ed92ae1a..2b28643d 100644 --- a/src/rasqal_rowsource_distinct.c +++ b/src/rasqal_rowsource_distinct.c @@ -216,7 +216,7 @@ rasqal_new_distinct_rowsource(rasqal_world *world, if(!world || !query || !rowsource) goto fail; - con = (rasqal_distinct_rowsource_context*)RASQAL_CALLOC(rasqal_distinct_rowsource_context, 1, sizeof(rasqal_distinct_rowsource_context)); + con = RASQAL_CALLOC(rasqal_distinct_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_rowsource_empty.c b/src/rasqal_rowsource_empty.c index 7741d506..ee99cefa 100644 --- a/src/rasqal_rowsource_empty.c +++ b/src/rasqal_rowsource_empty.c @@ -133,7 +133,7 @@ rasqal_new_empty_rowsource(rasqal_world *world, rasqal_query* query) if(!world || !query) return NULL; - con = (rasqal_empty_rowsource_context*)RASQAL_CALLOC(rasqal_empty_rowsource_context, 1, sizeof(rasqal_empty_rowsource_context)); + con = RASQAL_CALLOC(rasqal_empty_rowsource_context*, 1, sizeof(*con)); if(!con) return NULL; diff --git a/src/rasqal_rowsource_filter.c b/src/rasqal_rowsource_filter.c index 2ca80e9c..2595267f 100644 --- a/src/rasqal_rowsource_filter.c +++ b/src/rasqal_rowsource_filter.c @@ -242,7 +242,7 @@ rasqal_new_filter_rowsource(rasqal_world *world, if(!world || !query || !rowsource || !expr) goto fail; - con = (rasqal_filter_rowsource_context*)RASQAL_CALLOC(rasqal_filter_rowsource_context, 1, sizeof(rasqal_filter_rowsource_context)); + con = RASQAL_CALLOC(rasqal_filter_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_rowsource_graph.c b/src/rasqal_rowsource_graph.c index c353a861..c80e601f 100644 --- a/src/rasqal_rowsource_graph.c +++ b/src/rasqal_rowsource_graph.c @@ -310,7 +310,7 @@ rasqal_new_graph_rowsource(rasqal_world *world, if(!world || !query || !rowsource || !var) return NULL; - con = (rasqal_graph_rowsource_context*)RASQAL_CALLOC(rasqal_graph_rowsource_context, 1, sizeof(rasqal_graph_rowsource_context)); + con = RASQAL_CALLOC(rasqal_graph_rowsource_context*, 1, sizeof(*con)); if(!con) return NULL; diff --git a/src/rasqal_rowsource_groupby.c b/src/rasqal_rowsource_groupby.c index 80c986bc..7a78282a 100644 --- a/src/rasqal_rowsource_groupby.c +++ b/src/rasqal_rowsource_groupby.c @@ -300,7 +300,7 @@ rasqal_groupby_rowsource_process(rasqal_rowsource* rowsource, node = (rasqal_groupby_tree_node*)raptor_avltree_search(con->tree, &key); if(!node) { /* New Group */ - node = (rasqal_groupby_tree_node*)RASQAL_CALLOC(rasqal_groupby_tree_node, sizeof(*node), 1); + node = RASQAL_CALLOC(rasqal_groupby_tree_node*, 1, sizeof(*node)); if(!node) { raptor_free_sequence(literal_seq); return 1; @@ -474,7 +474,7 @@ rasqal_new_groupby_rowsource(rasqal_world *world, if(!world || !query) return NULL; - con = (rasqal_groupby_rowsource_context*)RASQAL_CALLOC(rasqal_groupby_rowsource_context, 1, sizeof(*con)); + con = RASQAL_CALLOC(rasqal_groupby_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_rowsource_having.c b/src/rasqal_rowsource_having.c index 89685c67..96a89552 100644 --- a/src/rasqal_rowsource_having.c +++ b/src/rasqal_rowsource_having.c @@ -265,7 +265,7 @@ rasqal_new_having_rowsource(rasqal_world *world, if(!world || !query || !rowsource || !exprs_seq) goto fail; - con = (rasqal_having_rowsource_context*)RASQAL_CALLOC(rasqal_having_rowsource_context, 1, sizeof(*con)); + con = RASQAL_CALLOC(rasqal_having_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_rowsource_join.c b/src/rasqal_rowsource_join.c index 0569cad7..a81d723d 100644 --- a/src/rasqal_rowsource_join.c +++ b/src/rasqal_rowsource_join.c @@ -210,7 +210,7 @@ rasqal_join_rowsource_ensure_variables(rasqal_rowsource* rowsource, return 1; map_size = rasqal_rowsource_get_size(con->right); - con->right_map = (int*)RASQAL_MALLOC(int, sizeof(int) * map_size); + con->right_map = RASQAL_MALLOC(int*, sizeof(int) * map_size); if(!con->right_map) return 1; @@ -574,7 +574,7 @@ rasqal_new_join_rowsource(rasqal_world *world, join_type != RASQAL_JOIN_TYPE_NATURAL) goto fail; - con = (rasqal_join_rowsource_context*)RASQAL_CALLOC(rasqal_join_rowsource_context, 1, sizeof(rasqal_join_rowsource_context)); + con = RASQAL_CALLOC(rasqal_join_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_rowsource_project.c b/src/rasqal_rowsource_project.c index 020306f5..321b912f 100644 --- a/src/rasqal_rowsource_project.c +++ b/src/rasqal_rowsource_project.c @@ -84,7 +84,7 @@ rasqal_project_rowsource_ensure_variables(rasqal_rowsource* rowsource, size = raptor_sequence_size(con->projection_variables); - con->projection = (int*)RASQAL_MALLOC(array, sizeof(int*) * size); + con->projection = RASQAL_MALLOC(int*, sizeof(int*) * size); if(!con->projection) return 1; @@ -272,7 +272,7 @@ rasqal_new_project_rowsource(rasqal_world *world, if(!world || !query || !rowsource || !projection_variables) goto fail; - con = (rasqal_project_rowsource_context*)RASQAL_CALLOC(rasqal_project_rowsource_context, 1, sizeof(rasqal_project_rowsource_context)); + con = RASQAL_CALLOC(rasqal_project_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_rowsource_rowsequence.c b/src/rasqal_rowsource_rowsequence.c index bcb53ac6..08fa59c1 100644 --- a/src/rasqal_rowsource_rowsequence.c +++ b/src/rasqal_rowsource_rowsequence.c @@ -238,7 +238,7 @@ rasqal_new_rowsequence_rowsource(rasqal_world *world, if(!raptor_sequence_size(rows_seq) || !raptor_sequence_size(vars_seq)) return NULL; - con = (rasqal_rowsequence_rowsource_context*)RASQAL_CALLOC(rasqal_rowsequence_rowsource_context, 1, sizeof(rasqal_rowsequence_rowsource_context)); + con = RASQAL_CALLOC(rasqal_rowsequence_rowsource_context*, 1, sizeof(*con)); if(!con) return NULL; diff --git a/src/rasqal_rowsource_sort.c b/src/rasqal_rowsource_sort.c index 84c62af7..54854b1c 100644 --- a/src/rasqal_rowsource_sort.c +++ b/src/rasqal_rowsource_sort.c @@ -264,7 +264,7 @@ rasqal_new_sort_rowsource(rasqal_world *world, if(!world || !query || !rowsource) goto fail; - con = (rasqal_sort_rowsource_context*)RASQAL_CALLOC(rasqal_sort_rowsource_context, 1, sizeof(rasqal_sort_rowsource_context)); + con = RASQAL_CALLOC(rasqal_sort_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_rowsource_triples.c b/src/rasqal_rowsource_triples.c index 4c5b4a7b..cadcbbf7 100644 --- a/src/rasqal_rowsource_triples.c +++ b/src/rasqal_rowsource_triples.c @@ -456,7 +456,7 @@ rasqal_new_triples_rowsource(rasqal_world *world, if(!triples) return rasqal_new_empty_rowsource(world, query); - con = (rasqal_triples_rowsource_context*)RASQAL_CALLOC(rasqal_triples_rowsource_context, 1, sizeof(rasqal_triples_rowsource_context)); + con = RASQAL_CALLOC(rasqal_triples_rowsource_context*, 1, sizeof(*con)); if(!con) return NULL; @@ -468,9 +468,8 @@ rasqal_new_triples_rowsource(rasqal_world *world, con->triples_count = con->end_column - con->start_column + 1; - con->triple_meta = (rasqal_triple_meta*)RASQAL_CALLOC(rasqal_triple_meta, - con->triples_count, - sizeof(rasqal_triple_meta)); + con->triple_meta = RASQAL_CALLOC(rasqal_triple_meta*, con->triples_count, + sizeof(rasqal_triple_meta)); if(!con->triple_meta) { rasqal_triples_rowsource_finish(NULL, con); return NULL; @@ -546,7 +545,7 @@ main(int argc, char *argv[]) query = rasqal_new_query(world, "sparql", NULL); data_string = raptor_uri_filename_to_uri_string(data_file); - query_string = (unsigned char*)RASQAL_MALLOC(cstring, strlen((const char*)data_string)+strlen(query_format)+1); + query_string = RASQAL_MALLOC(unsigned char*, strlen((const char*)data_string) + strlen(query_format) + 1); sprintf((char*)query_string, query_format, data_string); raptor_free_memory(data_string); @@ -571,7 +570,7 @@ main(int argc, char *argv[]) goto tidy; } - RASQAL_FREE(cstring, query_string); + RASQAL_FREE(char*, query_string); query_string = NULL; triples = rasqal_query_get_triple_sequence(query); diff --git a/src/rasqal_rowsource_union.c b/src/rasqal_rowsource_union.c index 83c2ef75..5b46016a 100644 --- a/src/rasqal_rowsource_union.c +++ b/src/rasqal_rowsource_union.c @@ -120,12 +120,12 @@ rasqal_union_rowsource_ensure_variables(rasqal_rowsource* rowsource, return 1; map_size = rasqal_rowsource_get_size(con->right); - con->right_map = (int*)RASQAL_MALLOC(int, sizeof(int) * map_size); + con->right_map = RASQAL_MALLOC(int*, sizeof(int) * map_size); if(!con->right_map) return 1; - con->right_tmp_values = (rasqal_literal**)RASQAL_MALLOC(ptrarray, - sizeof(rasqal_literal*) * map_size); + con->right_tmp_values = RASQAL_MALLOC(rasqal_literal**, + sizeof(rasqal_literal*) * map_size); if(!con->right_tmp_values) return 1; @@ -394,7 +394,7 @@ rasqal_new_union_rowsource(rasqal_world *world, if(!world || !query || !left || !right) goto fail; - con = (rasqal_union_rowsource_context*)RASQAL_CALLOC(rasqal_union_rowsource_context, 1, sizeof(rasqal_union_rowsource_context)); + con = RASQAL_CALLOC(rasqal_union_rowsource_context*, 1, sizeof(*con)); if(!con) goto fail; diff --git a/src/rasqal_service.c b/src/rasqal_service.c index 31f97622..2c7d6ea7 100644 --- a/src/rasqal_service.c +++ b/src/rasqal_service.c @@ -97,7 +97,7 @@ rasqal_new_service(rasqal_world* world, raptor_uri* service_uri, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(service_uri, raptor_uri, NULL); - svc = (rasqal_service*)RASQAL_CALLOC(rasqal_service, 1, sizeof(*svc)); + svc = RASQAL_CALLOC(rasqal_service*, 1, sizeof(*svc)); if(!svc) return NULL; @@ -106,7 +106,7 @@ rasqal_new_service(rasqal_world* world, raptor_uri* service_uri, if(query_string) { len = strlen((const char*)query_string); - svc->query_string = (char*)RASQAL_MALLOC(cstring, len + 1); + svc->query_string = RASQAL_MALLOC(char*, len + 1); if(!svc->query_string) { rasqal_free_service(svc); return NULL; @@ -156,7 +156,7 @@ rasqal_free_service(rasqal_service* svc) raptor_free_uri(svc->service_uri); if(svc->query_string) - RASQAL_FREE(cstring, svc->query_string); + RASQAL_FREE(char*, svc->query_string); if(svc->data_graphs) raptor_free_sequence(svc->data_graphs); @@ -203,7 +203,7 @@ rasqal_service_set_format(rasqal_service* svc, const char *format) size_t len; if(svc->format) { - RASQAL_FREE(cstring, svc->format); + RASQAL_FREE(char*, svc->format); svc->format = NULL; } @@ -211,7 +211,7 @@ rasqal_service_set_format(rasqal_service* svc, const char *format) return 0; len = strlen(format); - svc->format = (char*)RASQAL_MALLOC(cstring, len + 1); + svc->format = RASQAL_MALLOC(char*, len + 1); if(!svc->format) return 1; @@ -247,10 +247,10 @@ rasqal_service_content_type_handler(raptor_www* www, void* userdata, size_t len; if(svc->content_type) - RASQAL_FREE(cstring, svc->content_type); + RASQAL_FREE(char*, svc->content_type); len = strlen(content_type); - svc->content_type = (char*)RASQAL_MALLOC(cstring, len + 1); + svc->content_type = RASQAL_MALLOC(char*, len + 1); if(svc->content_type) { char* p; @@ -491,7 +491,7 @@ rasqal_service_execute(rasqal_service* svc) } if(svc->content_type) { - RASQAL_FREE(cstring, svc->content_type); + RASQAL_FREE(char*, svc->content_type); svc->content_type = NULL; } diff --git a/src/rasqal_solution_modifier.c b/src/rasqal_solution_modifier.c index 0703dbbe..25259314 100644 --- a/src/rasqal_solution_modifier.c +++ b/src/rasqal_solution_modifier.c @@ -65,8 +65,7 @@ rasqal_new_solution_modifier(rasqal_query* query, RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(query, rasqal_query, NULL); - sm = (rasqal_solution_modifier*)RASQAL_CALLOC(rasqal_solution_modifier, - 1, sizeof(*sm)); + sm = RASQAL_CALLOC(rasqal_solution_modifier*, 1, sizeof(*sm)); if(!sm) return NULL; diff --git a/src/rasqal_triple.c b/src/rasqal_triple.c index e8fb208b..b0bf107f 100644 --- a/src/rasqal_triple.c +++ b/src/rasqal_triple.c @@ -60,7 +60,7 @@ rasqal_new_triple(rasqal_literal* subject, rasqal_literal* predicate, { rasqal_triple* t; - t = (rasqal_triple*)RASQAL_CALLOC(rasqal_triple, 1, sizeof(*t)); + t = RASQAL_CALLOC(rasqal_triple*, 1, sizeof(*t)); if(t) { t->subject = subject; t->predicate = predicate; @@ -91,7 +91,7 @@ rasqal_new_triple_from_triple(rasqal_triple* t) { rasqal_triple* newt; - newt = (rasqal_triple*)RASQAL_CALLOC(rasqal_triple, 1, sizeof(*newt)); + newt = RASQAL_CALLOC(rasqal_triple*, 1, sizeof(*newt)); if(newt) { newt->subject = rasqal_new_literal_from_literal(t->subject); newt->predicate = rasqal_new_literal_from_literal(t->predicate); diff --git a/src/rasqal_triples_source.c b/src/rasqal_triples_source.c index f8da5caa..9f138a81 100644 --- a/src/rasqal_triples_source.c +++ b/src/rasqal_triples_source.c @@ -125,12 +125,11 @@ rasqal_new_triples_source(rasqal_query* query) rasqal_triples_source* rts; int rc = 0; - rts = (rasqal_triples_source*)RASQAL_CALLOC(rasqal_triples_source, 1, - sizeof(rasqal_triples_source)); + rts = RASQAL_CALLOC(rasqal_triples_source*, 1, sizeof(*rts)); if(!rts) return NULL; - rts->user_data = RASQAL_CALLOC(user_data, 1, rtsf->user_data_size); + rts->user_data = RASQAL_CALLOC(void*, 1, rtsf->user_data_size); if(!rts->user_data) { RASQAL_FREE(rasqal_triples_source, rts); return NULL; @@ -235,8 +234,7 @@ rasqal_new_triples_match(rasqal_query* query, if(!triples_source) return NULL; - rtm = (rasqal_triples_match *)RASQAL_CALLOC(rasqal_triples_match, 1, - sizeof(rasqal_triples_match)); + rtm = RASQAL_CALLOC(rasqal_triples_match*, 1, sizeof(*rtm)); if(rtm) { rtm->world = query->world; diff --git a/src/rasqal_update.c b/src/rasqal_update.c index 0b080af0..0fff01e4 100644 --- a/src/rasqal_update.c +++ b/src/rasqal_update.c @@ -115,7 +115,7 @@ rasqal_new_update_operation(rasqal_update_type type, return NULL; } - update = (rasqal_update_operation*)RASQAL_MALLOC(update_operation, sizeof(*update)); + update = RASQAL_MALLOC(rasqal_update_operation*, sizeof(*update)); if(!update) return NULL; diff --git a/src/rasqal_variable.c b/src/rasqal_variable.c index ca827a72..4f4e81f7 100644 --- a/src/rasqal_variable.c +++ b/src/rasqal_variable.c @@ -92,7 +92,7 @@ rasqal_free_variable(rasqal_variable* v) return; if(v->name) - RASQAL_FREE(cstring, (void*)v->name); + RASQAL_FREE(char*, v->name); if(v->value) rasqal_free_literal(v->value); @@ -254,8 +254,7 @@ rasqal_new_variables_table(rasqal_world* world) { rasqal_variables_table* vt; - vt = (rasqal_variables_table*)RASQAL_CALLOC(rasqal_variables_table, 1, - sizeof(rasqal_variables_table)); + vt = RASQAL_CALLOC(rasqal_variables_table*, 1, sizeof(*vt)); if(!vt) return NULL; @@ -370,14 +369,13 @@ rasqal_variables_table_add(rasqal_variables_table* vt, if(!strcmp((const char*)v->name, (const char*)name)) { /* variable with this name already present */ - RASQAL_FREE(cstring, name); + RASQAL_FREE(char*, name); return rasqal_new_variable_from_variable(v); } } - v = (rasqal_variable*)RASQAL_CALLOC(rasqal_variable, 1, - sizeof(rasqal_variable)); + v = RASQAL_CALLOC(rasqal_variable*, 1, sizeof(*v)); if(v) { v->usage = 1; @@ -415,7 +413,7 @@ rasqal_variables_table_add(rasqal_variables_table* vt, vt->variable_names = NULL; } } else { - RASQAL_FREE(cstring, name); + RASQAL_FREE(char*, name); if(value) rasqal_free_literal(value); } @@ -538,7 +536,8 @@ rasqal_variables_table_get_names(rasqal_variables_table* vt) if(!vt->variable_names && size) { int i; - vt->variable_names = (const unsigned char**)RASQAL_CALLOC(cstrings, sizeof(unsigned char*), (size + 1)); + vt->variable_names = RASQAL_CALLOC(const unsigned char**, + sizeof(unsigned char*), (size + 1)); if(!vt->variable_names) return NULL; diff --git a/src/rasqal_xsd_datatypes.c b/src/rasqal_xsd_datatypes.c index 7ddfde62..f5a320f9 100644 --- a/src/rasqal_xsd_datatypes.c +++ b/src/rasqal_xsd_datatypes.c @@ -280,7 +280,7 @@ rasqal_xsd_format_integer(int i, size_t *len_p) * (the lexical form may have leading 0s in non-canonical representations) */ #define INTEGER_BUFFER_SIZE 20 - string = (unsigned char*)RASQAL_MALLOC(cstring, INTEGER_BUFFER_SIZE + 1); + string = RASQAL_MALLOC(unsigned char*, INTEGER_BUFFER_SIZE + 1); if(!string) return NULL; /* snprintf() takes as length the buffer size including NUL */ @@ -308,7 +308,7 @@ rasqal_xsd_format_float(float f, size_t *len_p) /* FIXME: This is big enough for C float formatted in decimal as %1g */ #define FLOAT_BUFFER_SIZE 30 - string = (unsigned char*)RASQAL_MALLOC(cstring, FLOAT_BUFFER_SIZE + 1); + string = RASQAL_MALLOC(unsigned char*, FLOAT_BUFFER_SIZE + 1); if(!string) return NULL; /* snprintf() takes as length the buffer size including NUL */ @@ -341,7 +341,7 @@ rasqal_xsd_format_double(double d, size_t *len_p) if(d == 0.0f) { len = 5; - buf = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + buf = RASQAL_MALLOC(unsigned char*, len + 1); if(!buf) return NULL; @@ -352,7 +352,7 @@ rasqal_xsd_format_double(double d, size_t *len_p) } len = 20; - buf = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + buf = RASQAL_MALLOC(unsigned char*, len + 1); if(!buf) return NULL; @@ -472,10 +472,9 @@ rasqal_xsd_init(rasqal_world* world) if(!world->xsd_namespace_uri) return 1; - world->xsd_datatype_uris = - (raptor_uri**)RASQAL_CALLOC(ptrarray, - SPARQL_XSD_NAMES_COUNT + 1, - sizeof(raptor_uri*)); + world->xsd_datatype_uris = RASQAL_CALLOC(raptor_uri**, + SPARQL_XSD_NAMES_COUNT + 1, + sizeof(raptor_uri*)); if(!world->xsd_datatype_uris) return 1; diff --git a/src/rdql_lexer.l b/src/rdql_lexer.l index ee3fcb65..f17db24c 100644 --- a/src/rdql_lexer.l +++ b/src/rdql_lexer.l @@ -420,10 +420,10 @@ rdql_copy_regex_token(rasqal_query* rq, YYSTYPE* lval, unsigned char delim) if(new_buffer_len < 10) new_buffer_len = 10; - new_buffer = (unsigned char*)RASQAL_CALLOC(cstring, 1, new_buffer_len + 1); + new_buffer = RASQAL_CALLOC(unsigned char*, 1, new_buffer_len + 1); if(buffer_len) { memcpy(new_buffer, buffer, buffer_len); - RASQAL_FREE(cstring, buffer); + RASQAL_FREE(char*, buffer); } buffer=new_buffer; buffer_len = new_buffer_len; @@ -437,7 +437,7 @@ rdql_copy_regex_token(rasqal_query* rq, YYSTYPE* lval, unsigned char delim) if(!buffer) { buffer_len = 0; - buffer = (unsigned char *)RASQAL_CALLOC(cstring, 1, buffer_len + 1); + buffer = RASQAL_CALLOC(unsigned char*, 1, buffer_len + 1); } buffer[ind] = '\0'; @@ -455,10 +455,10 @@ rdql_copy_regex_token(rasqal_query* rq, YYSTYPE* lval, unsigned char delim) if(new_flags_len<5) new_flags_len = 5; - new_flags = (unsigned char*)RASQAL_CALLOC(cstring, 1, new_flags_len + 1); + new_flags = RASQAL_CALLOC(unsigned char*, 1, new_flags_len + 1); if(flags_len) { memcpy(new_flags, flags, flags_len); - RASQAL_FREE(cstring, flags); + RASQAL_FREE(char*, flags); } flags = new_flags; flags_len = new_flags_len; @@ -487,7 +487,7 @@ rdql_copy_string_token(rasqal_query* rq, YYSTYPE* lval, raptor_uri *dt_uri = NULL; unsigned char *dt_qname = NULL; - string = (unsigned char *)RASQAL_MALLOC(cstring, len + 1); + string = RASQAL_MALLOC(unsigned char*, len + 1); for(s = text, d = string, i = 0; i < len; s++, i++) { unsigned char c = *s; @@ -511,14 +511,14 @@ rdql_copy_string_token(rasqal_query* rq, YYSTYPE* lval, s++; i++; if(i + ulen > len) { printf("\\%c over end of line", c); - RASQAL_FREE(cstring, string); + RASQAL_FREE(char*, string); return 1; } n = sscanf((const char*)s, ((ulen == 4) ? "%04lx" : "%08lx"), &unichar); if(n != 1) { rdql_syntax_error(rq, "RDQL syntax error - Illegal Unicode escape '%c%s...'", c, s); - RASQAL_FREE(cstring, string); + RASQAL_FREE(char*, string); return 1; } @@ -527,7 +527,7 @@ rdql_copy_string_token(rasqal_query* rq, YYSTYPE* lval, if(unichar > 0x10ffff) { rdql_syntax_error(rq, "RDQL syntax error - Illegal Unicode character with code point #x%lX.", unichar); - RASQAL_FREE(cstring, string); + RASQAL_FREE(char*, string); return 1; } @@ -576,7 +576,7 @@ rdql_copy_string_token(rasqal_query* rq, YYSTYPE* lval, if(language) { char *new_language; size_t new_language_len = strlen((const char*)language); - new_language = (char*)RASQAL_MALLOC(cstring, new_language_len + 1); + new_language = RASQAL_MALLOC(char*, new_language_len + 1); memcpy(new_language, language, new_language_len + 1); language = new_language; } @@ -593,7 +593,7 @@ rdql_copy_string_token(rasqal_query* rq, YYSTYPE* lval, rdql_syntax_warning(rq, "Invalid RDQL name \"%s\"", dt); /* the qname is expanded later */ - dt_qname = (unsigned char*)RASQAL_MALLOC(cstring, dt_qname_len + 1); + dt_qname = RASQAL_MALLOC(unsigned char*, dt_qname_len + 1); memcpy(dt_qname, dt, dt_qname_len + 1); } } @@ -1092,11 +1092,11 @@ rdql_token_free(rasqal_world* world, int token, YYSTYPE *lval) raptor_free_uri(lval->uri); break; case IDENTIFIER: - RASQAL_FREE(cstring, lval->name); + RASQAL_FREE(char*, lval->name); break; case QNAME_LITERAL: if(lval->name) - RASQAL_FREE(cstring, lval->name); + RASQAL_FREE(char*, lval->name); break; default: break; @@ -1141,7 +1141,7 @@ main(int argc, char *argv[]) filename = argv[1]; } - query_string = (char*)RASQAL_CALLOC(cstring, FILE_READ_BUF_SIZE, 1); + query_string = RASQAL_CALLOC(char*, FILE_READ_BUF_SIZE, 1); fh = fopen(filename, "r"); if(fh) { fread(query_string, FILE_READ_BUF_SIZE, 1, fh); @@ -1168,7 +1168,7 @@ main(int argc, char *argv[]) #endif len = strlen((const char*)query_string); - buf = (char *)RASQAL_MALLOC(cstring, len + 3); + buf = RASQAL_MALLOC(char*, len + 3); memcpy(buf, query_string, len); buf[len] = ' '; buf[len + 1] = buf[len + 2] = '\0'; /* YY_END_OF_BUFFER_CHAR; */ @@ -1202,13 +1202,13 @@ main(int argc, char *argv[]) } if(buf) - RASQAL_FREE(cstring, buf); + RASQAL_FREE(char*, buf); yylex_destroy(scanner); raptor_free_uri(rq.base_uri); - RASQAL_FREE(cstring, query_string); + RASQAL_FREE(char*, query_string); rasqal_free_world(world); diff --git a/src/rdql_parser.y b/src/rdql_parser.y index a870bb77..67c1f642 100644 --- a/src/rdql_parser.y +++ b/src/rdql_parser.y @@ -189,7 +189,7 @@ static void rdql_query_error(rasqal_query* rq, const char *message); %destructor { if($$) - RASQAL_FREE(cstring, $$); + RASQAL_FREE(char*, $$); } QNAME_LITERAL IDENTIFIER %% diff --git a/src/sparql_lexer.l b/src/sparql_lexer.l index 8a2d8801..56c0ee78 100644 --- a/src/sparql_lexer.l +++ b/src/sparql_lexer.l @@ -469,7 +469,7 @@ EXPONENT [eE][+-]?[0-9]+ ":=" { return ASSIGN; } "@"{LANGUAGETOKEN} { - sparql_parser_lval->name = (unsigned char*)RASQAL_MALLOC(cstring, yyleng); + sparql_parser_lval->name = RASQAL_MALLOC(unsigned char*, yyleng); if(!sparql_parser_lval->name) YY_REPORT_ERROR_EOF("Out of memory"); @@ -539,7 +539,7 @@ EXPONENT [eE][+-]?[0-9]+ BEGIN(INITIAL); len = raptor_stringbuffer_length(rqe->sb); - sparql_parser_lval->name = (unsigned char *)RASQAL_MALLOC(cstring, len+1); + sparql_parser_lval->name = RASQAL_MALLOC(unsigned char*, len + 1); if(!sparql_parser_lval->name) YY_REPORT_ERROR_EOF("Out of memory"); @@ -594,7 +594,7 @@ EXPONENT [eE][+-]?[0-9]+ BEGIN(INITIAL); len = raptor_stringbuffer_length(rqe->sb); - sparql_parser_lval->name = (unsigned char *)RASQAL_MALLOC(cstring, len+1); + sparql_parser_lval->name = RASQAL_MALLOC(unsigned char*, len + 1); if(!sparql_parser_lval->name) YY_REPORT_ERROR_EOF("Out of memory"); @@ -744,7 +744,7 @@ EXPONENT [eE][+-]?[0-9]+ YY_REPORT_ERROR_EOF("rasqal_escaped_name_to_utf8_string failed"); sparql_parser_lval->uri = raptor_new_uri_relative_to_base(rq->world->raptor_world_ptr, rq->base_uri, uri_string); - RASQAL_FREE(cstring, uri_string); + RASQAL_FREE(char*, uri_string); if(!sparql_parser_lval->uri) YY_REPORT_ERROR_EOF("raptor_new_uri_relative_to_base failed"); } @@ -873,7 +873,7 @@ sparql_copy_qname(rasqal_query *rq, const unsigned char *text, size_t len) uri = raptor_qname_string_to_uri(rq->namespaces, s, dest_len); #endif - RASQAL_FREE(cstring, s); + RASQAL_FREE(char*, s); return uri; } @@ -900,7 +900,7 @@ sparql_copy_string_token(rasqal_query* rq, len = raptor_stringbuffer_length(sb); } - string = (unsigned char*)RASQAL_MALLOC(cstring, len + 1); + string = RASQAL_MALLOC(unsigned char*, len + 1); if(string) { if(sb) raptor_stringbuffer_copy_to_string(sb, string, len + 1); @@ -985,7 +985,7 @@ sparql_stringbuffer_append_sparql_string(rasqal_query* rq, unsigned char *d; unsigned char *string; - string = (unsigned char *)RASQAL_MALLOC(cstring, len + 1); + string = RASQAL_MALLOC(unsigned char*, len + 1); if(!string) return -1; @@ -1016,7 +1016,7 @@ sparql_stringbuffer_append_sparql_string(rasqal_query* rq, s++; i++; if(i + ulen > len) { sparql_syntax_error(rq, "SPARQL string \\%c over end of line", c); - RASQAL_FREE(cstring, string); + RASQAL_FREE(char*, string); return 1; } @@ -1024,7 +1024,7 @@ sparql_stringbuffer_append_sparql_string(rasqal_query* rq, if(n != 1) { sparql_syntax_error(rq, "Bad SPARQL string Uncode escape '%c%s...'", c, s); - RASQAL_FREE(cstring, string); + RASQAL_FREE(char*, string); return 1; } @@ -1035,7 +1035,7 @@ sparql_stringbuffer_append_sparql_string(rasqal_query* rq, sparql_syntax_error(rq, "Bad SPARQL string Unicode character with code point #x%lX (max #x%lX).", unichar, rasqal_unicode_max_codepoint); - RASQAL_FREE(cstring, string); + RASQAL_FREE(char*, string); return 1; } @@ -1831,11 +1831,11 @@ sparql_token_free(rasqal_world* world, int token, YYSTYPE *lval) case IDENTIFIER: case BLANK_LITERAL: case PREFIX: - RASQAL_FREE(cstring, lval->name); + RASQAL_FREE(char*, lval->name); break; case QNAME_LITERAL: if(lval->name) - RASQAL_FREE(cstring, lval->name); + RASQAL_FREE(char*, lval->name); break; default: break; @@ -1880,7 +1880,7 @@ main(int argc, char *argv[]) filename = argv[1]; } - query_string = (char*)RASQAL_CALLOC(cstring, FILE_READ_BUF_SIZE, 1); + query_string = RASQAL_CALLOC(char*, FILE_READ_BUF_SIZE, 1); fh = fopen(filename, "r"); if(fh) { fread(query_string, FILE_READ_BUF_SIZE, 1, fh); @@ -1899,7 +1899,7 @@ main(int argc, char *argv[]) scanner = sparql.scanner; len = strlen((const char*)query_string); - buf = (char *)RASQAL_MALLOC(cstring, len+3); + buf = RASQAL_MALLOC(char*, len + 3); memcpy(buf, query_string, len); buf[len] = ' '; buf[len+1] = buf[len+2] = '\0'; /* YY_END_OF_BUFFER_CHAR; */ @@ -1933,13 +1933,13 @@ main(int argc, char *argv[]) } if(buf) - RASQAL_FREE(cstring, buf); + RASQAL_FREE(char*, buf); yylex_destroy(scanner); raptor_free_uri(rq.base_uri); - RASQAL_FREE(cstring, query_string); + RASQAL_FREE(char*, query_string); rasqal_free_world(world); diff --git a/src/sparql_parser.y b/src/sparql_parser.y index 8e89cefc..9c660597 100644 --- a/src/sparql_parser.y +++ b/src/sparql_parser.y @@ -105,7 +105,8 @@ static sparql_uri_applies* new_uri_applies(raptor_uri* uri, rasqal_update_graph_applies applies) { sparql_uri_applies* ua; - ua = (sparql_uri_applies*)RASQAL_MALLOC(uri_applies, sizeof(*ua)); + + ua = RASQAL_MALLOC(sparql_uri_applies*, sizeof(*ua)); if(!ua) return NULL; @@ -361,7 +362,7 @@ URI_LITERAL URI_LITERAL_BRACE %destructor { if($$) - RASQAL_FREE(cstring, $$); + RASQAL_FREE(char*, $$); } STRING QNAME_LITERAL QNAME_LITERAL_BRACE BLANK_LITERAL IDENTIFIER @@ -632,7 +633,7 @@ PrefixDeclListOpt: PrefixDeclListOpt PREFIX IDENTIFIER URI_LITERAL sparql_syntax_warning(((rasqal_query*)rq), "PREFIX %s can be defined only once.", prefix_string ? (const char*)prefix_string : ":"); - RASQAL_FREE(cstring, prefix_string); + RASQAL_FREE(char*, prefix_string); raptor_free_uri($4); } else { rasqal_prefix *p; diff --git a/src/timegm.c b/src/timegm.c index 4b5a8eac..501280cb 100644 --- a/src/timegm.c +++ b/src/timegm.c @@ -58,7 +58,7 @@ rasqal_timegm(struct tm *tm) tzset(); if(zone) - RASQAL_FREE(cstring, zone); + RASQAL_FREE(char*, zone); return result; } diff --git a/tests/engine/rasqal_construct_test.c b/tests/engine/rasqal_construct_test.c index 3b9b0c16..91047621 100644 --- a/tests/engine/rasqal_construct_test.c +++ b/tests/engine/rasqal_construct_test.c @@ -110,7 +110,7 @@ main(int argc, char **argv) { data_dir_string = raptor_uri_filename_to_uri_string(argv[1]); - query_string = (unsigned char*)RASQAL_MALLOC(cstring, strlen((const char*)data_dir_string)+strlen(data_file)+strlen(query_format)+1); + query_string = RASQAL_MALLOC(unsigned char*, strlen((const char*)data_dir_string) + strlen(data_file) + strlen(query_format) + 1); sprintf((char*)query_string, query_format, data_dir_string, data_file); raptor_free_memory(data_dir_string); @@ -130,7 +130,7 @@ main(int argc, char **argv) { goto done; } - RASQAL_FREE(cstring, query_string); + RASQAL_FREE(char*, query_string); printf("%s: executing query\n", program); results = rasqal_query_execute(query); diff --git a/tests/engine/rasqal_limit_test.c b/tests/engine/rasqal_limit_test.c index 412b5b91..7038d30d 100644 --- a/tests/engine/rasqal_limit_test.c +++ b/tests/engine/rasqal_limit_test.c @@ -127,7 +127,7 @@ main(int argc, char **argv) { unsigned char *query_string; data_string=raptor_uri_filename_to_uri_string(argv[1]); - query_string=(unsigned char*)RASQAL_MALLOC(cstring, strlen((const char*)data_string)+strlen(query_format)+1); + query_string = RASQAL_MALLOC(unsigned char*, strlen((const char*)data_string) + strlen(query_format) + 1); sprintf((char*)query_string, query_format, data_string); raptor_free_memory(data_string); @@ -240,7 +240,7 @@ main(int argc, char **argv) { } /* end test loop */ - RASQAL_FREE(cstring, query_string); + RASQAL_FREE(char*, query_string); } /* end query loop */ diff --git a/tests/engine/rasqal_order_test.c b/tests/engine/rasqal_order_test.c index b291b455..a21f5f43 100644 --- a/tests/engine/rasqal_order_test.c +++ b/tests/engine/rasqal_order_test.c @@ -117,7 +117,7 @@ main(int argc, char **argv) { data_dir_string=raptor_uri_filename_to_uri_string(argv[1]); - query_string=(unsigned char*)RASQAL_MALLOC(cstring, strlen((const char*)data_dir_string)+strlen(animals)+strlen(query_format)+1); + query_string = RASQAL_MALLOC(unsigned char*, strlen((const char*)data_dir_string) + strlen(animals) + strlen(query_format) + 1); sprintf((char*)query_string, query_format, data_dir_string, animals, limit, offset); raptor_free_memory(data_dir_string); @@ -136,7 +136,7 @@ main(int argc, char **argv) { return(1); } - RASQAL_FREE(cstring, query_string); + RASQAL_FREE(char*, query_string); printf("%s: executing query %d limit %d offset %d\n", program, i, limit, offset);