Aspects


vs


Home Page
About Us

Free

Free is a function to deallocate memory obtained from malloc and other functions in C. Do not use this tag to refer to free software

Strdup

The strdup() function duplicates a string



Others

Example

In c memory most other things are managed by the programmer so strdup is no worse than forgetting to free malloc ed memory failing to null terminate a string using incorrect format string in scanf and invoking undefined behaviour accessing dangling pointer etc

from question  

Why is strdup considered to be evil

That requires the caller to take the responsibility of free ing the reversed string;strdup is not a great function because it needs to find the length of the string that is being duplicated which means you end up traversing one extra time

from question  

Reverse strings

Back to Home
Data comes from Stack Exchange with CC-BY-SA-4.0