Merge pull request #177 from libtom/remove-opt-cast remove OPT_CAST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
diff --git a/bn_mp_fwrite.c b/bn_mp_fwrite.c
index 9f0c3df..8f236ab 100644
--- a/bn_mp_fwrite.c
+++ b/bn_mp_fwrite.c
@@ -22,7 +22,7 @@ int mp_fwrite(const mp_int *a, int radix, FILE *stream)
return err;
}
- buf = OPT_CAST(char) XMALLOC((size_t)len);
+ buf = (char*) XMALLOC((size_t)len);
if (buf == NULL) {
return MP_MEM;
}
diff --git a/bn_mp_grow.c b/bn_mp_grow.c
index 1d92b29..fe36d3d 100644
--- a/bn_mp_grow.c
+++ b/bn_mp_grow.c
@@ -29,7 +29,7 @@ int mp_grow(mp_int *a, int size)
* in case the operation failed we don't want
* to overwrite the dp member of a.
*/
- tmp = OPT_CAST(mp_digit) XREALLOC(a->dp, sizeof(mp_digit) * (size_t)size);
+ tmp = (mp_digit*) XREALLOC(a->dp, sizeof(mp_digit) * (size_t)size);
if (tmp == NULL) {
/* reallocation failed but "a" is still valid [can be freed] */
return MP_MEM;
diff --git a/bn_mp_init.c b/bn_mp_init.c
index 7520089..c66c46c 100644
--- a/bn_mp_init.c
+++ b/bn_mp_init.c
@@ -18,7 +18,7 @@ int mp_init(mp_int *a)
int i;
/* allocate memory required and clear it */
- a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof(mp_digit) * (size_t)MP_PREC);
+ a->dp = (mp_digit*) XMALLOC(sizeof(mp_digit) * (size_t)MP_PREC);
if (a->dp == NULL) {
return MP_MEM;
}
diff --git a/bn_mp_init_size.c b/bn_mp_init_size.c
index 9b933fb..8f5f642 100644
--- a/bn_mp_init_size.c
+++ b/bn_mp_init_size.c
@@ -21,7 +21,7 @@ int mp_init_size(mp_int *a, int size)
size += (MP_PREC * 2) - (size % MP_PREC);
/* alloc mem */
- a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof(mp_digit) * (size_t)size);
+ a->dp = (mp_digit*) XMALLOC(sizeof(mp_digit) * (size_t)size);
if (a->dp == NULL) {
return MP_MEM;
}
diff --git a/bn_mp_prime_random_ex.c b/bn_mp_prime_random_ex.c
index b0b4632..5909085 100644
--- a/bn_mp_prime_random_ex.c
+++ b/bn_mp_prime_random_ex.c
@@ -46,7 +46,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
bsize = (size>>3) + ((size&7)?1:0);
/* we need a buffer of bsize bytes */
- tmp = OPT_CAST(unsigned char) XMALLOC((size_t)bsize);
+ tmp = (unsigned char*) XMALLOC((size_t)bsize);
if (tmp == NULL) {
return MP_MEM;
}
diff --git a/bn_mp_shrink.c b/bn_mp_shrink.c
index ff7905f..e033fcc 100644
--- a/bn_mp_shrink.c
+++ b/bn_mp_shrink.c
@@ -23,7 +23,7 @@ int mp_shrink(mp_int *a)
}
if (a->alloc != used) {
- if ((tmp = OPT_CAST(mp_digit) XREALLOC(a->dp, sizeof(mp_digit) * (size_t)used)) == NULL) {
+ if ((tmp = (mp_digit*) XREALLOC(a->dp, sizeof(mp_digit) * (size_t)used)) == NULL) {
return MP_MEM;
}
a->dp = tmp;
diff --git a/tommath_private.h b/tommath_private.h
index 48cf37d..26ce161 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -24,15 +24,6 @@
#ifdef __cplusplus
extern "C" {
-
-/* C++ compilers don't like assigning void * to mp_digit * */
-#define OPT_CAST(x) (x *)
-
-#else
-
-/* C on the other hand doesn't care */
-#define OPT_CAST(x)
-
#endif
/* define heap macros */