Back to index

glibc  2.9
Defines | Functions
strndup.c File Reference
#include <stdio.h>
#include <sys/types.h>

Go to the source code of this file.


#define __strndup   strndup


char * malloc ()
char * __strndup (char *s, size_t n) const

Define Documentation

#define __strndup   strndup

Definition at line 37 of file strndup.c.

Function Documentation

char* __strndup ( char *  s,
size_t  n 
) const

Definition at line 41 of file strndup.c.

  size_t len = __strnlen (s, n);
  char *new = (char *) malloc (len + 1);

  if (new == NULL)
    return NULL;

  new[len] = '\0';
  return (char *) memcpy (new, s, len);

Here is the call graph for this function:

char* malloc ( )