What is Nostr?
anna /
npub1f67…s5qm
2023-11-06 23:01:00
in reply to nevent1q…lpsc

anna on Nostr: UsernameSwift ☭ :verifiedaroace: Phineas 'fossoid' Holstrom buy robux today :ROBUX: ...

UsernameSwift ☭ :verifiedaroace: (npub1zt2…ccgj) Phineas 'fossoid' Holstrom (npub1vhx…sekz) buy robux today :ROBUX: (npub1wg0…t0yf) you don’t need to cast any pointer to/from void pointers actually.

this is valid and generates no warnings with -Wall -Wpedantic -fanalyzer:

#include <stdio.h>
#include <stdlib.h>

struct nya {
int foo;
int bar;
};

void nya(void *mew) {
struct nya *meow = mew;
printf("%d, %d\n", meow->foo, meow->bar);
}

int main() {
struct nya foo = { .foo = 5, .bar = 10 };
nya(&foo);
return 0;
}


so not only malloc, realloc, and free, void* in general are exempt from casts

(but do remember strict aliasing rules. you can’t put a type into a void pointer, and then turn it into another type)
Author Public Key
npub1f67qrzm95xe497g0jda70x6uxwr9ru2j39sg38axfj4ff05c979qmps5qm