| iMatix home page | << | < | > | >> |
![]() Version 1.91 |
#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 */ word lineno /* Line number in calling source */ )
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.
{ char *copy; if (string) /* If string not null, copy it */ { copy = mem alloc (trn, strlen (string) + 1, filename, lineno); if (copy) strcpy (copy, string); } else copy = NULL; /* Just pass-through a NULL */ return (copy); }
| << | < | > | >> |
![]() |