Move strdup() fallback implementation to platform code.

This commit is contained in:
Joachim Nilsson 2010-07-24 02:02:56 +02:00
parent ceb1995733
commit a848011073
2 changed files with 15 additions and 15 deletions

View File

@ -23,21 +23,6 @@
#define MAX_TOTAL_MATCHES (256 << sizeof(char *))
#ifndef HAVE_STRDUP
/* Return an allocated copy of a string. */
char *strdup(const char *p)
{
char *new = malloc(sizeof(char) * strlen(p));
if (new) {
strcpy(new, p);
return new;
}
return NULL;
}
#endif
/* Wrap strcmp() for qsort() */
static int compare(const void *p1, const void *p2)
{

View File

@ -142,6 +142,21 @@ void rl_ttyset(int Reset)
#error Unsupported platform, missing tcgetattr(), termio.h and sgtty.h
#endif /* Neither HAVE_SGTTY_H, HAVE_TERMIO_H or HAVE_TCGETATTR */
#ifndef HAVE_STRDUP
/* Return an allocated copy of a string. */
char *strdup(const char *p)
{
char *new = malloc(sizeof(char) * strlen(p));
if (new) {
strcpy(new, p);
return new;
}
return NULL;
}
#endif
void rl_add_slash(char *path, char *p)
{
struct stat Sb;