better casting

This commit is contained in:
jacekpoz 2024-03-11 17:52:32 +01:00
parent 2e62adfa57
commit f23d8a1fb4
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -20,15 +20,14 @@ void test_queue(size_t size) {
}
for (size_t i = 0; i < 50; ++i) {
void *val_ptr = queue_read(q);
if (val_ptr == NULL) {
int64_t *val = (int64_t*)queue_read(q);
if (val == NULL) {
printf("%zu: queue is empty!\n", i);
break;
}
int64_t val = *(int64_t*)val_ptr;
printf("%zu: read %ld from queue\n", i, val);
free(val_ptr);
printf("%zu: read %ld from queue\n", i, *val);
free(val);
}
queue_free(q);
@ -48,15 +47,14 @@ void test_stack(size_t size) {
}
for (size_t i = 0; i < 50; ++i) {
void *val_ptr = stack_pop(s);
if (val_ptr == NULL) {
int64_t *val = (int64_t*)stack_pop(s);
if (val == NULL) {
printf("%zu: stack is empty!\n", i);
break;
}
int64_t val = *(int64_t*)val_ptr;
printf("%zu: popped %ld from stack\n", i, val);
free(val_ptr);
printf("%zu: popped %ld from stack\n", i, *val);
free(val);
}
stack_free(s);