In C, why do some people cast the pointer before freeing it?
I'm working on an old code base and pretty much every invocation of free() uses a cast on its argument. For example, free((float *)velocity); free((float *)acceleration); free((char *)label);where each pointer is of the corresponding (and matching) type. I see no point in doing this at all. It's very old code, so I'm left wondering if it's a K&R thing. If so, I actually wish to support the old compilers that may have required this, so I don't want to remove them.Is there a technical reason to use these casts? I don't even see much of a pragmatic reason to use them. What's the point of reminding ourselves of the data type right before freeing it?EDIT: This question is *not* a duplicate of the other question. The other question is a special case of this question, which I think is obvious if the close voters would read all the answers.Colophon: I'm giving the "const answer" the checkmark because it is a bonafide real reason why this might need to be done; however, the answer about it being a pre-ANSI C custom (at least among some programmers) seems to be the reason it was used in my case. Lots of good points by many people here. Thank you for your contributions.