Using the pointer to your old memory to hold the return value of a realloc call is bad form, if that call fails then realloc isn't required to clean up the old allocated memory and you just lost your pointer to it so now you have a memory leak. Most people will use a temp pointer to hold the realloc call to check if it's null and then move your original pointer to the temp one.

Type casting malloc and realloc is pretty useless as well since C does type coercion from void to any other type automatically.

0

"The best optimizer is between your ears" - Michael Abrash
Saying you can optimize a program is like saying you understand how a program works on every level of every facet on a specific machines configuration.

Yeah if you need clarity it can help if you know what you're doing.It can cause problems as well and I usually recommend newer programmers to stay away from it. Depending on the compiler you're using if you cast malloc and forget to include the stdlib.h header file you could end up with broken code that compiles. Personally I'd just add a comment block if I need clarity that bad over telling the compiler that you're smarter than it via casting when it's not necessary.

"The best optimizer is between your ears" - Michael Abrash
Saying you can optimize a program is like saying you understand how a program works on every level of every facet on a specific machines configuration.