Practice ยท 1 of 4
Allocation Failure Contracts
Implement the documented-contract pair:
``c
/* duplicates s into fresh heap memory; sets *out and returns 1 on success.
Returns 0 WITHOUT touching *out on: NULL s, NULL out, or allocation
failure. */
int safe_dup(const char *s, char **out);
/* joins two strings into fresh memory "a/b" (separator always present);
same contract as safe_dup. */
int path_join(const char *a, const char *b, char **out);
``
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Failure-Path Gym