From bcdb9db57e8f68ba90077a77a4152b72ca6da7ac Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 16 Jan 2012 22:23:42 +0000 Subject: Support compilation as C++ under MSVC++. git-svn-id: http://svn.drobilla.net/sord/trunk@194 3d64ff67-21c5-427c-a301-fe4f08042e5a --- src/zix/common.h | 15 ++++++++++++--- src/zix/hash.c | 2 +- src/zix/tree.c | 4 ++-- src/zix/tree.h | 2 -- 4 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/zix') diff --git a/src/zix/common.h b/src/zix/common.h index 2f63fca..e7d35e1 100644 --- a/src/zix/common.h +++ b/src/zix/common.h @@ -17,8 +17,6 @@ #ifndef ZIX_COMMON_H #define ZIX_COMMON_H -#include - /** @addtogroup zix @{ @@ -43,6 +41,12 @@ #endif /** @endcond */ +#ifdef __cplusplus +extern "C" { +#else +# include +#endif + typedef enum { ZIX_STATUS_SUCCESS, ZIX_STATUS_ERROR, @@ -61,7 +65,12 @@ typedef int (*ZixComparator)(const void* a, const void* b, void* user_data); */ typedef bool (*ZixEqualFunc)(const void* a, const void* b); -/**@} +/** + @} */ +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* ZIX_COMMON_H */ diff --git a/src/zix/hash.c b/src/zix/hash.c index c267757..f654e91 100644 --- a/src/zix/hash.c +++ b/src/zix/hash.c @@ -55,7 +55,7 @@ zix_hash_new(ZixHashFunc hash_func, hash->key_equal_func = key_equal_func; hash->count = 0; hash->n_buckets = &sizes[0]; - hash->buckets = malloc(*hash->n_buckets * sizeof(Entry*)); + hash->buckets = (Entry**)malloc(*hash->n_buckets * sizeof(Entry*)); memset(hash->buckets, 0, *hash->n_buckets * sizeof(Entry*)); return hash; diff --git a/src/zix/tree.c b/src/zix/tree.c index 066b038..64e6e7c 100644 --- a/src/zix/tree.c +++ b/src/zix/tree.c @@ -47,7 +47,7 @@ ZIX_API ZixTree* zix_tree_new(bool allow_duplicates, ZixComparator cmp, void* cmp_data) { - ZixTree* t = malloc(sizeof(ZixTree)); + ZixTree* t = (ZixTree*)malloc(sizeof(ZixTree)); t->root = NULL; t->cmp = cmp; t->cmp_data = cmp_data; @@ -287,7 +287,7 @@ zix_tree_insert(ZixTree* t, void* e, ZixTreeIter** ti) } // Allocate a new node n - if (!(n = malloc(sizeof(ZixTreeNode)))) { + if (!(n = (ZixTreeNode*)malloc(sizeof(ZixTreeNode)))) { return ZIX_STATUS_NO_MEM; } memset(n, '\0', sizeof(ZixTreeNode)); diff --git a/src/zix/tree.h b/src/zix/tree.h index 670c437..bcbde26 100644 --- a/src/zix/tree.h +++ b/src/zix/tree.h @@ -17,8 +17,6 @@ #ifndef ZIX_TREE_H #define ZIX_TREE_H -#include - #include "zix/common.h" #ifdef __cplusplus -- cgit v1.2.1