9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

strdup.c (174B)


      1 #include <u.h>
      2 #include <libc.h>
      3 
      4 char*
      5 strdup(char *s)
      6 {
      7 	char *t;
      8 	int l;
      9 
     10 	l = strlen(s);
     11 	t = malloc(l+1);
     12 	if(t == nil)
     13 		return nil;
     14 	memmove(t, s, l+1);
     15 	return t;
     16 }
     17