|
Lines 41-46
Link Here
|
| 41 |
/* Crank this up as needed */ |
41 |
/* Crank this up as needed */ |
| 42 |
#define TEMPBUFSIZE 65536 |
42 |
#define TEMPBUFSIZE 65536 |
| 43 |
|
43 |
|
|
|
44 |
#ifdef __FreeBSD__ |
| 45 |
char* t_strndup(const char* string, size_t n) |
| 46 |
{ |
| 47 |
char* copy_string = 0; |
| 48 |
|
| 49 |
if(0 == string || 0 == n) |
| 50 |
return 0; |
| 51 |
|
| 52 |
copy_string = (char*) malloc(n + 1); |
| 53 |
if(0 == copy_string) |
| 54 |
return 0; |
| 55 |
|
| 56 |
memcpy(copy_string, string, n); |
| 57 |
*(copy_string + n) = '\0'; |
| 58 |
|
| 59 |
return copy_string; |
| 60 |
} |
| 61 |
#endif |
| 62 |
|
| 44 |
/* Local functions */ |
63 |
/* Local functions */ |
| 45 |
static char * read_stdio(FILE *); |
64 |
static char * read_stdio(FILE *); |
| 46 |
static int write_stdio(FILE *, char *, int); |
65 |
static int write_stdio(FILE *, char *, int); |
|
Lines 91-97
Link Here
|
| 91 |
result[i+1] = NULL; |
110 |
result[i+1] = NULL; |
| 92 |
} |
111 |
} |
| 93 |
else { |
112 |
else { |
|
|
113 |
#ifdef __FreeBSD__ |
| 114 |
result[i] = t_strndup(*envp, equ - *envp); |
| 115 |
#else |
| 94 |
result[i] = strndup(*envp, equ - *envp); |
116 |
result[i] = strndup(*envp, equ - *envp); |
|
|
117 |
#endif |
| 95 |
result[i+1] = strdup(equ + 1); |
118 |
result[i+1] = strdup(equ + 1); |
| 96 |
} |
119 |
} |
| 97 |
} |
120 |
} |