@ -24,14 +24,14 @@ int main() {
char* parent = path_parent(path);
printf("Parent: %s\n", parent);
path_free(path);
path_free(&path);
char* parent_of_parent = path_parent(parent);
printf("Parent of parent: %s\n", parent_of_parent);
path_free(parent);
path_free(parent_of_parent);
path_free(&parent);
path_free(&parent_of_parent);
return EXIT_SUCCESS;
}
```
@ -124,9 +124,9 @@ char* path_join(unsigned int count, ...) {
// Frees path and sets pointer to NULL
void path_free(char* path) {
free(path);
path = NULL;
void path_free(char** path) {
free(*path);
*path = NULL;
/*
@ -171,7 +171,8 @@ char* path_parent(const char* path) {
base_path[last_separator_index] = '\0';
// free temporary cleaned path
path_free(clean_path);
path_free(&clean_path);
return base_path;
@ -32,10 +32,10 @@ Be sure to path_free() after use.
char* path_join(unsigned int count, ...);
void path_free(char* path);
void path_free(char** path);
Creates a new path pointing to the parent.
Be sure to path_free() on the base as well after use.
*/
char* path_parent(const char* path);
@ -22,13 +22,13 @@ int main() {