I am reading a book (Programming with POSIX Threads by Butenhof, 1997) that uses C, and I came across the following line:
(void)free(data);
Here, data
is just a pointer to an allocated struct,
data = malloc(sizeof(my_struct_t));
Why is the result of free
being cast to void
?
From my understanding of C, this doesn't seem to make sense for two reasons:
void
The book was written in 1997. Is this some sort of legacy thing?
The author mentions that the examples were run on Digital Unix 4.0d, but I still can't imagine a reason to ever cast the result of a function if you're not going to use that result.