Back to index

lightning-sunbird  0.9+nobinonly
Functions
strdup.c File Reference
#include "plstr.h"
#include "prmem.h"
#include <string.h>

Go to the source code of this file.

Functions

 PL_strdup (const char *s)
 PL_strfree (char *s)
 PL_strndup (const char *s, PRUint32 max)

Function Documentation

PL_strdup ( const char *  s)

Definition at line 43 of file strdup.c.

{
    char *rv;
    size_t n;

    if( (const char *)0 == s )
        s = "";

    n = strlen(s) + 1;

    rv = (char *)malloc(n);
    if( (char *)0 == rv ) return rv;

    (void)memcpy(rv, s, n);

    return rv;
}

Here is the call graph for this function:

PL_strfree ( char *  s)

Definition at line 62 of file strdup.c.

{
    free(s);
}
PL_strndup ( const char *  s,
PRUint32  max 
)

Definition at line 68 of file strdup.c.

{
    char *rv;
    size_t l;

    if( (const char *)0 == s )
        s = "";

    l = PL_strnlen(s, max);

    rv = (char *)malloc(l+1);
    if( (char *)0 == rv ) return rv;

    (void)memcpy(rv, s, l);
    rv[l] = '\0';

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function: