Changeset 095003a8 in mainline for uspace/lib/libc/generic


Ignore:
Timestamp:
2009-04-09T22:32:23Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4b1535
Parents:
7afb4a5
Message:

strdup() → str_dup()

Location:
uspace/lib/libc/generic
Files:
2 edited

Legend:

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

    r7afb4a5 r095003a8  
    4141#include <errno.h>
    4242#include <align.h>
     43#include <mem.h>
    4344#include <string.h>
    4445
     
    807808}
    808809
    809 char *strncpy(char *dest, const char *src, size_t n)
    810 {
    811         char *orig = dest;
    812        
    813         while ((*(dest++) = *(src++)) && --n)
    814                 ;
    815         return orig;
    816 }
    817 
    818810char *strcat(char *dest, const char *src)
    819811{
     
    827819}
    828820
    829 char * strdup(const char *s1)
    830 {
    831         size_t len = str_size(s1) + 1;
    832         void *ret = malloc(len);
    833 
    834         if (ret == NULL)
     821char *str_dup(const char *src)
     822{
     823        size_t size = str_size(src);
     824        void *dest = malloc(size + 1);
     825
     826        if (dest == NULL)
    835827                return (char *) NULL;
    836828
    837         return (char *) memcpy(ret, s1, len);
     829        return (char *) memcpy(dest, src, size + 1);
    838830}
    839831
  • uspace/lib/libc/generic/vfs/vfs.c

    r7afb4a5 r095003a8  
    100100         * though they both point into the same dynamically allocated buffer.
    101101         */
    102         ncwd_path = strdup(ncwd_path);
     102        ncwd_path = str_dup(ncwd_path);
    103103        free(ncwd_path_nc);
    104104        if (!ncwd_path) {
Note: See TracChangeset for help on using the changeset viewer.