21#include "../utils/utils.h"
44 return (
ft_strncmp((
char *) a, (
char *) b, len));
53static void *
copy(
void *str)
84 return (
err(
"malloc()", 0));
85 paths_uniq = (
char **)
dedupe(
void ** arr_free(void **arr)
Free each element in a null-terminated array, and then the array itself.
void ** dedupe(void **arr, int(*compare)(void *, void *), void *(*copy)(void *))
Create new null-terminated array containing only unique values from arr, checked with compare,...
void * err(const char *str, void *retval)
Wrapper around perror() that always returns retval.
char ** ft_split(char const *s, char c)
Split string s by characer c into allocated array of strings, with NULL as the last element.
char * ft_strjoin(char const *s1, char const *s2)
Allocates enough space for and appends string s2 to string s1 and returns the new string.
size_t ft_strlen(const char *str)
Get length of str.
int ft_strncmp(const char *s1, const char *s2, size_t n)
Compare up to n characters of string s1 with string s2.
static void * copy(void *str)
Duplicate a path string and append a forward slash.
char ** get_paths(char **envp)
Create a null-terminated, unique array of paths from the environment pointer envp....
static int compare(void *a, void *b)
Compare path string a against path string b, which will always have a trailing forward slash.