Changeset 566987b0 in mainline


Ignore:
Timestamp:
2008-07-30T16:58:14Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2a513972
Parents:
29f8f8e
Message:

Add strdup(), contributed by Tim Post.

Location:
uspace/lib/libc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/string.c

    r29f8f8e r566987b0  
    3939#include <align.h>
    4040#include <sys/types.h>
    41 
     41#include <malloc.h>
    4242
    4343/* Dummy implementation of mem/ functions */
     
    354354}
    355355
     356char * strdup(const char *s1)
     357{
     358        size_t len = strlen(s1) + 1;
     359        void *ret = malloc(len);
     360
     361        if (ret == NULL)
     362                return (char *) NULL;
     363
     364        return (char *) memcpy(ret, s1, len);
     365}
     366
    356367/** @}
    357368 */
  • uspace/lib/libc/include/string.h

    r29f8f8e r566987b0  
    5656extern size_t strlen(const char *);
    5757
     58extern char *strdup(const char *);
     59
    5860extern char *strchr(const char *, int);
    5961extern char *strrchr(const char *, int);
Note: See TracChangeset for help on using the changeset viewer.