aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-10 02:58:25 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-10 02:58:25 +0100
commit344273a7e0a6899451836e6072fecebea4a6ac24 (patch)
treeea24fa9e12ae6dad40eeb6470c92545e14f0f8cf /src/mds-kbdc
parentno more direct allocations, always use macros, unless using alloca (diff)
downloadmds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.gz
mds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.bz2
mds-344273a7e0a6899451836e6072fecebea4a6ac24.tar.xz
add xmemdup macro
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-kbdc')
-rw-r--r--src/mds-kbdc/include-stack.c3
-rw-r--r--src/mds-kbdc/raw-data.c3
-rw-r--r--src/mds-kbdc/string.c3
3 files changed, 3 insertions, 6 deletions
diff --git a/src/mds-kbdc/include-stack.c b/src/mds-kbdc/include-stack.c
index b34b57b..d9225a3 100644
--- a/src/mds-kbdc/include-stack.c
+++ b/src/mds-kbdc/include-stack.c
@@ -199,8 +199,7 @@ mds_kbdc_include_stack_t* mds_kbdc_include_stack_save(void)
if (latest_save->ptr == 0)
return latest_save;
- fail_if (xmalloc(latest_save->stack, latest_save->ptr, const mds_kbdc_tree_include_t*));
- memcpy(latest_save->stack, includes, latest_save->ptr * sizeof(const mds_kbdc_tree_include_t*));
+ fail_if (xmemdup(latest_save->stack, includes, latest_save->ptr, const mds_kbdc_tree_include_t*));
return latest_save;
fail:
diff --git a/src/mds-kbdc/raw-data.c b/src/mds-kbdc/raw-data.c
index cf48486..d8976ec 100644
--- a/src/mds-kbdc/raw-data.c
+++ b/src/mds-kbdc/raw-data.c
@@ -408,8 +408,7 @@ int read_source_lines(const char* restrict pathname, mds_kbdc_source_code_t* res
}
/* Simplify file. */
- fail_if (xmalloc(real_content, content_size, char));
- memcpy(real_content, content, content_size * sizeof(char));
+ fail_if (xmemdup(real_content, content, content_size, char));
real_content_size = content_size;
content_size = remove_comments(content, content_size);
fail_if (xxrealloc(old, content, content_size, char));
diff --git a/src/mds-kbdc/string.c b/src/mds-kbdc/string.c
index 6ecf757..843757b 100644
--- a/src/mds-kbdc/string.c
+++ b/src/mds-kbdc/string.c
@@ -145,8 +145,7 @@ char32_t* string_dup(const char32_t* restrict string)
if (string == NULL)
return NULL;
n = string_length(string) + 1;
- fail_if (xmalloc(rc, n, char32_t));
- memcpy(rc, string, n * sizeof(char32_t));
+ fail_if (xmemdup(rc, string, n, char32_t));
return rc;
fail:
return NULL;