3 ms·
strndup is part of the "standard", but not present on some platforms unfortunately. :( I can't think of a modern C runtime that doesn't offer strdup, though. T
by thomaslee 14y ago
strndup is part of the "standard", but not present on some platforms unfortunately. :( I can't think of a modern C runtime that doesn't offer strdup, though.
The realloc check is good advice -- take heed, OP. :)
- halayli 14y agoTrue, strndup is relatively new (~7 years) to POSIX standard.
- kgabis 14y agoRealloc, strdup and strndup errors are handled as of now :) (https://github.com/kgabis/parson/commit/ee9be98974b3fdac0be1cc370bec948613e725d7 https://github.com/kgabis/parson/commit/ee9be98974b3fdac0be1...) And yes, I've written my own strndup because it's "relatively new".