src/pEp_string.h
changeset 2376 997e80887f22
child 2377 008d02a90566
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/pEp_string.h	Mon Jan 15 11:09:36 2018 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +// This file is under GNU General Public License 3.0
     1.5 +// see LICENSE.txt
     1.6 +
     1.7 +#pragma once
     1.8 +
     1.9 +#include <string.h>
    1.10 +#include "dynamic_api.h"
    1.11 +
    1.12 +#ifdef __cplusplus
    1.13 +extern "C" {
    1.14 +#endif
    1.15 +
    1.16 +
    1.17 +// new_string() - allocate a new string
    1.18 +//
    1.19 +//  parameters:
    1.20 +//      src (in)        string to copy or NULL
    1.21 +//      len (in)        length of newly created string or 0 for default
    1.22 +//
    1.23 +//  return value:
    1.24 +//      pointer to string object or NULL if out of memory
    1.25 +//
    1.26 +//  caveat:
    1.27 +//      one of the two parameters has to be set at least
    1.28 +
    1.29 +DYNAMIC_API char * new_string(const char *src, size_t len);
    1.30 +
    1.31 +
    1.32 +// free_string() - free memory occupied by string
    1.33 +//
    1.34 +//  parameters:
    1.35 +//      ts (in)         pointer to string to free
    1.36 +
    1.37 +DYNAMIC_API void free_string(char *s);
    1.38 +
    1.39 +
    1.40 +// string_dup() - duplicate a string
    1.41 +//
    1.42 +//  parameters:
    1.43 +//      src (in)        string to duplicate
    1.44 +//      len (in)        length of newly created string or 0 for default
    1.45 +//
    1.46 +//  return value:
    1.47 +//      pointer to copy or NULL if out of memory
    1.48 +
    1.49 +DYNAMIC_API char * string_dup(const char *src, size_t len);
    1.50 +
    1.51 +
    1.52 +#ifdef __cplusplus
    1.53 +}
    1.54 +#endif
    1.55 +