summaryrefslogtreecommitdiff
path: root/src/turtle_common.c
diff options
context:
space:
mode:
authorDave Beckett <dave@dajobe.org>2011-07-31 19:00:36 -0700
committerDave Beckett <dave@dajobe.org>2011-07-31 19:00:36 -0700
commitd24e9f9e9d7e120d8189a96590bf530868398a50 (patch)
treefb1a750c148ca008dca26558a0a036f031f454e5 /src/turtle_common.c
parent72fbe1883d7377e08b119c37a1fa90c830f41c0f (diff)
downloadraptor-d24e9f9e9d7e120d8189a96590bf530868398a50.tar.gz
Code style change and cleanup for alloc/free macros
Code style: 1. var = RAPTOR_CALLOC(type, count, size) Prefering: var = RAPTOR_CALLOC(type, 1, sizeof(*var)) when count = 1 2. var = RAPTOR_MALLOC(type, size) 3. RAPTOR_FREE(type, var) The consequence here is allocs that mostly fit into 1 line without so much boilerplate and duplication of types. The RAPTOR_MALLOC and RAPTOR_CALLOC now do the cast to the return type. RAPTOR_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.
Diffstat (limited to 'src/turtle_common.c')
-rw-r--r--src/turtle_common.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/turtle_common.c b/src/turtle_common.c
index 64fbed9b..b3c0b462 100644
--- a/src/turtle_common.c
+++ b/src/turtle_common.c
@@ -75,7 +75,7 @@ raptor_stringbuffer_append_turtle_string(raptor_stringbuffer* stringbuffer,
size_t i;
const unsigned char *s;
unsigned char *d;
- unsigned char *string = (unsigned char *)RAPTOR_MALLOC(cstring, len+1);
+ unsigned char *string = RAPTOR_MALLOC(unsigned char*, len + 1);
if(!string)
return -1;
@@ -103,7 +103,7 @@ raptor_stringbuffer_append_turtle_string(raptor_stringbuffer* stringbuffer,
if(i+ulen > len) {
error_handler(error_data,
"Turtle string error - \\%c over end of line", c);
- RAPTOR_FREE(cstring, string);
+ RAPTOR_FREE(char*, string);
return 1;
}
@@ -112,7 +112,7 @@ raptor_stringbuffer_append_turtle_string(raptor_stringbuffer* stringbuffer,
error_handler(error_data,
"Turtle string error - illegal Uncode escape '%c%s...'",
c, s);
- RAPTOR_FREE(cstring, string);
+ RAPTOR_FREE(char*, string);
return 1;
}
@@ -123,7 +123,7 @@ raptor_stringbuffer_append_turtle_string(raptor_stringbuffer* stringbuffer,
error_handler(error_data,
"Turtle string error - illegal Unicode character with code point #x%lX (max #x%lX).",
unichar, raptor_unicode_max_codepoint);
- RAPTOR_FREE(cstring, string);
+ RAPTOR_FREE(char*, string);
return 1;
}