Skip to content

Commit

Permalink
Remove strdup implementation (#447)
Browse files Browse the repository at this point in the history
Every platform we support has strdup, so this can be removed.
  • Loading branch information
derobins committed Sep 25, 2023
1 parent bb23516 commit 9a53936
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
37 changes: 0 additions & 37 deletions hdf/src/hdfalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,40 +118,3 @@ HIstrncpy(char *dest, const char *source, intn len)
*dest = '\0'; /* Force the last byte be '\0' */
return (destp);
} /* end HIstrncpy() */
/* *INDENT-OFF* */
/* GNU indent 1.9.1 urps on this section, so turn off indenting for now -QAK */

/*--------------------------------------------------------------------------
NAME
strdup -- in-library replacement for non-ANSI strdup()
USAGE
char *strdup(s)
const char *s; IN: pointer to the string to duplicate
RETURNS
Pointer to the duplicated string, or NULL on failure.
DESCRIPTION
Duplicates a string (i.e. allocates space and copies it over).
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Acts like strdup().
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
char *
strdup(const char *s)
{
char *ret;

/* Make sure original string is not NULL */
if (s == NULL)
return (NULL);

/* Allocate space */
ret = (char *)malloc((uint32)strlen(s) + 1);
if (ret == NULL)
return (NULL);

/* Copy the original string and return it */
strcpy(ret, s);
return (ret);
} /* end strdup() */
2 changes: 0 additions & 2 deletions hdf/src/hproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,6 @@ HDFLIBAPI char *HIstrncpy(char *dest, const char *source, intn len);

HDFLIBAPI int32 HDspaceleft(void);

HDFPUBLIC char *strdup(const char *s);

HDFLIBAPI intn HDc2fstr(char *str, intn len);

HDFLIBAPI char *HDf2cstring(_fcd fdesc, intn len);
Expand Down

0 comments on commit 9a53936

Please sign in to comment.