better casting
This commit is contained in:
parent
2e62adfa57
commit
f23d8a1fb4
1 changed files with 8 additions and 10 deletions
|
@ -20,15 +20,14 @@ void test_queue(size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < 50; ++i) {
|
for (size_t i = 0; i < 50; ++i) {
|
||||||
void *val_ptr = queue_read(q);
|
int64_t *val = (int64_t*)queue_read(q);
|
||||||
if (val_ptr == NULL) {
|
if (val == NULL) {
|
||||||
printf("%zu: queue is empty!\n", i);
|
printf("%zu: queue is empty!\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t val = *(int64_t*)val_ptr;
|
printf("%zu: read %ld from queue\n", i, *val);
|
||||||
printf("%zu: read %ld from queue\n", i, val);
|
free(val);
|
||||||
free(val_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
queue_free(q);
|
queue_free(q);
|
||||||
|
@ -48,15 +47,14 @@ void test_stack(size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < 50; ++i) {
|
for (size_t i = 0; i < 50; ++i) {
|
||||||
void *val_ptr = stack_pop(s);
|
int64_t *val = (int64_t*)stack_pop(s);
|
||||||
if (val_ptr == NULL) {
|
if (val == NULL) {
|
||||||
printf("%zu: stack is empty!\n", i);
|
printf("%zu: stack is empty!\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t val = *(int64_t*)val_ptr;
|
printf("%zu: popped %ld from stack\n", i, *val);
|
||||||
printf("%zu: popped %ld from stack\n", i, val);
|
free(val);
|
||||||
free(val_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_free(s);
|
stack_free(s);
|
||||||
|
|
Loading…
Reference in a new issue