Skip to content
Browse files

Code style change and cleanup for alloc/free macros

Code style:
  1. var = RASQAL_CALLOC(type, nmem, size)
  Prefering:
    var = RASQAL_CALLOC(type, 1, sizeof(*var))
  when nmem = 1

  2. var = RASQAL_CALLOC(type, size)

  3. RASQAL_FREE(type, var)

The consequence here is allocs that mostly fit into 1 line without so
much boilerplate and duplication of types.

The RASQAL_MALLOC and RASQAL_CALLOC now do the cast to the return type.

RASQAL_FREE takes the object type too but always casts arg to void
This certainly contains many wrong types to the arg but might be
used later in some kind of smart type-aware debugging allocator.
  • Loading branch information...
1 parent 944e0b4 commit 86678bb85d88438260e848e0779e27387657b120 @dajobe committed Jul 31, 2011
Showing with 315 additions and 343 deletions.
  1. +3 −5 src/rasqal_algebra.c
  2. +1 −2 src/rasqal_bindings.c
  3. +5 −5 src/rasqal_data_graph.c
  4. +3 −5 src/rasqal_dataset.c
  5. +13 −13 src/rasqal_datetime.c
  6. +5 −4 src/rasqal_decimal.c
  7. +2 −3 src/rasqal_engine_sort.c
  8. +13 −14 src/rasqal_expr.c
  9. +1 −1 src/rasqal_expr_datetimes.c
  10. +9 −9 src/rasqal_expr_evaluate.c
  11. +3 −3 src/rasqal_expr_numerics.c
  12. +10 −10 src/rasqal_expr_strings.c
  13. +2 −2 src/rasqal_format_rdf.c
  14. +7 −7 src/rasqal_format_sparql_xml.c
  15. +3 −4 src/rasqal_format_table.c
  16. +1 −1 src/rasqal_formula.c
  17. +14 −14 src/rasqal_general.c
  18. +1 −1 src/rasqal_graph.c
  19. +1 −2 src/rasqal_graph_pattern.c
  20. +7 −7 src/rasqal_internal.h
  21. +47 −48 src/rasqal_literal.c
  22. +2 −2 src/rasqal_map.c
  23. +3 −3 src/rasqal_prefix.c
  24. +1 −2 src/rasqal_projection.c
  25. +6 −7 src/rasqal_query.c
  26. +3 −4 src/rasqal_query_results.c
  27. +2 −2 src/rasqal_query_test.c
  28. +10 −12 src/rasqal_query_transform.c
  29. +11 −14 src/rasqal_raptor.c
  30. +10 −12 src/rasqal_result_formats.c
  31. +9 −10 src/rasqal_row.c
  32. +2 −2 src/rasqal_row_compatible.c
  33. +1 −2 src/rasqal_rowsource.c
  34. +7 −9 src/rasqal_rowsource_aggregation.c
  35. +1 −1 src/rasqal_rowsource_assignment.c
  36. +1 −1 src/rasqal_rowsource_distinct.c
  37. +1 −1 src/rasqal_rowsource_empty.c
  38. +1 −1 src/rasqal_rowsource_filter.c
  39. +1 −1 src/rasqal_rowsource_graph.c
  40. +2 −2 src/rasqal_rowsource_groupby.c
  41. +1 −1 src/rasqal_rowsource_having.c
  42. +2 −2 src/rasqal_rowsource_join.c
  43. +2 −2 src/rasqal_rowsource_project.c
  44. +1 −1 src/rasqal_rowsource_rowsequence.c
  45. +1 −1 src/rasqal_rowsource_sort.c
  46. +5 −6 src/rasqal_rowsource_triples.c
  47. +4 −4 src/rasqal_rowsource_union.c
  48. +8 −8 src/rasqal_service.c
  49. +1 −2 src/rasqal_solution_modifier.c
  50. +2 −2 src/rasqal_triple.c
  51. +3 −5 src/rasqal_triples_source.c
  52. +1 −1 src/rasqal_update.c
  53. +7 −8 src/rasqal_variable.c
  54. +7 −8 src/rasqal_xsd_datatypes.c
  55. +17 −17 src/rdql_lexer.l
  56. +1 −1 src/rdql_parser.y
  57. +16 −16 src/sparql_lexer.l
  58. +4 −3 src/sparql_parser.y
  59. +1 −1 src/timegm.c
  60. +2 −2 tests/engine/rasqal_construct_test.c
  61. +2 −2 tests/engine/rasqal_limit_test.c
  62. +2 −2 tests/engine/rasqal_order_test.c
View
8 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;
View
3 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;
View
10 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)
View
8 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;
View
26 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;
View
9 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;
View
5 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;
View
27 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;
View
2 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);
View
18 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;
View
6 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,15 +292,15 @@ 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;
output_len = rasqal_digest_buffer(md_type, output, s, len);
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;
View
20 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)
View
4 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;
View
14 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;
View
7 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;
View
2 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;
View
28 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);
}
View
2 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;
View
3 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;
View
14 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;
View
95 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,17 +2057,17 @@ 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);
}
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);
View
4 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);
View
6 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);
View
3 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;
View
13 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;
View
7 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;
View
4 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);
View
22 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;
View
25 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;
View
22 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,16 +287,15 @@ 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;
formatter->factory = factory;
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,16 +548,15 @@ 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;
for(from = p, to = suffix; *from; ) {
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);
View
19 src/rasqal_row.c
@@ -48,24 +48,24 @@ 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;
row->usage = 1;
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,