(fix of commit
8086c72)
Issue #201 (bdwgc).
* tests/disclaim_bench.c (testobj_new): Replace GC_MALLOC(sizeof T)
with GC_NEW(T).
* tests/staticrootslib.c (libsrl_mktree): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/disclaim_bench.c (testobj_new): Cast GC_finalized_malloc()
result to testobj_t.
* tests/disclaim_bench.c (main): Cast GC_MALLOC() result to testobj_t*.
* tests/disclaim_test.c (pair_dct): Cast obj to pair_t.
* tests/disclaim_test.c (pair_dct): Cast cd to pair_t.
* tests/disclaim_test.c (GC_finalized_malloc): Cast
GC_finalized_malloc() result to pair_t.
* tests/staticrootslib.c (root_nz): Cast element to struct treenode*.
* tests/staticrootstest.c (root_nz): Likewise.
* tests/staticrootslib.c (libsrl_mktree): Cast GC_MALLOC_ATOMIC()
result to struct treenode*.
* tests/trace_test.c (mktree): Likewise.
* tests/staticrootstest.c (init_staticroot): Cast libsrl_init() result
to char*.
* tests/thread_leak_test.c (main): Cast malloc() result to int*.
testobj_t obj;
switch (model) {
case 0:
- obj = GC_MALLOC(sizeof(struct testobj_s));
+ obj = GC_NEW(struct testobj_s);
if (obj != NULL)
GC_REGISTER_FINALIZER_NO_ORDER(obj, testobj_finalize,
&free_count, NULL, NULL);
break;
case 1:
- obj = GC_finalized_malloc(sizeof(struct testobj_s), &fclos);
+ obj = (testobj_t)GC_finalized_malloc(sizeof(struct testobj_s),
+ &fclos);
break;
case 2:
- obj = GC_MALLOC(sizeof(struct testobj_s));
+ obj = GC_NEW(struct testobj_s);
break;
default:
exit(-1);
model_max = 2;
}
- keep_arr = GC_MALLOC(sizeof(void *) * KEEP_CNT);
+ keep_arr = (testobj_t *)GC_MALLOC(sizeof(void *) * KEEP_CNT);
if (NULL == keep_arr) {
fprintf(stderr, "Out of memory!\n");
exit(3);
void GC_CALLBACK pair_dct(void *obj, void *cd)
{
- pair_t p = obj;
+ pair_t p = (pair_t)obj;
int checksum;
/* Check that obj and its car and cdr are not trashed. */
/* Invalidate it. */
memset(p->magic, '*', sizeof(p->magic));
p->checksum = 0;
- p->car = cd;
+ p->car = (pair_t)cd;
p->cdr = NULL;
}
pair_t p;
static const struct GC_finalizer_closure fc = { pair_dct, NULL };
- p = GC_finalized_malloc(sizeof(struct pair_s), &fc);
+ p = (pair_t)GC_finalized_malloc(sizeof(struct pair_s), &fc);
if (p == NULL) {
fprintf(stderr, "Out of memory!\n");
exit(3);
};
static struct treenode *root[10] = { 0 };
-static struct treenode *root_nz[10] = { (void *)(GC_word)2 };
+static struct treenode *root_nz[10] = { (struct treenode *)(GC_word)2 };
#ifdef STATICROOTSLIB2
# define libsrl_getpelem libsrl_getpelem2
GC_TEST_EXPORT_API struct treenode * libsrl_mktree(int i)
{
- struct treenode * r = GC_MALLOC(sizeof(struct treenode));
- if (0 == i) return 0;
- if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+ struct treenode * r = GC_NEW(struct treenode);
+ if (0 == i)
+ return 0;
+ if (1 == i)
+ r = (struct treenode *)GC_MALLOC_ATOMIC(sizeof(struct treenode));
if (r) {
r -> x = libsrl_mktree(i-1);
r -> y = libsrl_mktree(i-1);
/* Same as "root" variable but initialized to some non-zero value (to */
/* be placed to .data section instead of .bss). */
-struct treenode *root_nz[10] = { (void *)(GC_word)1 };
+struct treenode *root_nz[10] = { (struct treenode *)(GC_word)1 };
static char *staticroot; /* intentionally static */
/* Intentionally put staticroot initialization in a function other */
/* than main to prevent CSA warning that staticroot variable can be */
/* changed to be a local one). */
- staticroot = libsrl_init();
+ staticroot = (char *)libsrl_init();
}
int main(void)
int *p[10];
int i;
for (i = 0; i < 10; ++i) {
- p[i] = malloc(sizeof(int)+i);
+ p[i] = (int *)malloc(sizeof(int) + i);
}
CHECK_LEAKS();
for (i = 1; i < 10; ++i) {
} * root[10];
struct treenode * mktree(int i) {
- struct treenode * r = GC_MALLOC(sizeof(struct treenode));
- if (0 == i) return 0;
- if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+ struct treenode * r = GC_NEW(struct treenode);
+ if (0 == i)
+ return 0;
+ if (1 == i)
+ r = (struct treenode *)GC_MALLOC_ATOMIC(sizeof(struct treenode));
if (r == NULL) {
fprintf(stderr, "Out of memory\n");
exit(1);