CLEANUP: remove unneeded casts
In C89, "void *" is automatically promoted to any pointer type. Casting
the result of malloc/calloc to the type of the LHS variable is therefore
unneeded.
Most of this patch was built using this Coccinelle patch:
@@
type T;
@@
- (T *)
(\(lua_touserdata\|malloc\|calloc\|SSL_get_app_data\|hlua_checkudata\|lua_newuserdata\)(...))
@@
type T;
T *x;
void *data;
@@
x =
- (T *)
data
@@
type T;
T *x;
T *data;
@@
x =
- (T *)
data
Unfortunately, either Coccinelle or I is too limited to detect situation
where a complex RHS expression is of type "void *" and therefore casting
is not needed. Those cases were manually examined and corrected.
diff --git a/src/shctx.c b/src/shctx.c
index a22730a..c561632 100644
--- a/src/shctx.c
+++ b/src/shctx.c
@@ -624,7 +624,7 @@
cur = &shctx->free;
for (i = 0 ; i < size ; i++) {
prev = cur;
- cur = (struct shared_block *)((char *)prev + sizeof(struct shared_block));
+ cur++;
prev->n = cur;
cur->p = prev;
}