| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

mem_strdup_

#include "sflmem.h"
char *
mem_strdup_ (
    MEMTRN     *trn,                    /*  Associated transaction           */
    const char *string,                 /*  String to copy                   */
    const char *filename,               /*  Name of source file making call  */
    size_t      lineno                  /*  Line number in calling source    */
)

Synopsis

Saves a string in dynamic memory. Use the mem_strdup macro to call this function! The caller is responsible for freeing the space allocated when it is no longer needed. Returns a pointer to the allocated string, which holds a copy of the parameter string. Returns NULL if there was insufficient heap storage available to allocate the string, or if the original string was itself NULL.

Source Code - (sflmem.c)

{
    char *copy;
    size_t str_len;

    if (string)                         /*  If string not null, copy it      */
      {
        str_len = strlen (string) + 1;
        copy = mem alloc  (trn, str_len, filename, lineno);
        if (copy)
            strncpy (copy, string, str_len);
      }
    else
        copy = NULL;                    /*  Just pass-through a NULL         */

    return (copy);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation