src/pEp_string.h
author Volker Birk <vb@pep.foundation>
Mon, 15 Jan 2018 12:23:56 +0100
changeset 2377 008d02a90566
parent 2376 997e80887f22
child 2378 b244047cdacc
permissions -rw-r--r--
typo
vb@2376
     1
// This file is under GNU General Public License 3.0
vb@2376
     2
// see LICENSE.txt
vb@2376
     3
vb@2376
     4
#pragma once
vb@2376
     5
vb@2376
     6
#include <string.h>
vb@2376
     7
#include "dynamic_api.h"
vb@2376
     8
vb@2376
     9
#ifdef __cplusplus
vb@2376
    10
extern "C" {
vb@2376
    11
#endif
vb@2376
    12
vb@2376
    13
vb@2376
    14
// new_string() - allocate a new string
vb@2376
    15
//
vb@2376
    16
//  parameters:
vb@2376
    17
//      src (in)        string to copy or NULL
vb@2376
    18
//      len (in)        length of newly created string or 0 for default
vb@2376
    19
//
vb@2376
    20
//  return value:
vb@2376
    21
//      pointer to string object or NULL if out of memory
vb@2376
    22
//
vb@2376
    23
//  caveat:
vb@2376
    24
//      one of the two parameters has to be set at least
vb@2376
    25
vb@2376
    26
DYNAMIC_API char * new_string(const char *src, size_t len);
vb@2376
    27
vb@2376
    28
vb@2376
    29
// free_string() - free memory occupied by string
vb@2376
    30
//
vb@2376
    31
//  parameters:
vb@2377
    32
//      s (in)          pointer to string to free
vb@2376
    33
vb@2376
    34
DYNAMIC_API void free_string(char *s);
vb@2376
    35
vb@2376
    36
vb@2376
    37
// string_dup() - duplicate a string
vb@2376
    38
//
vb@2376
    39
//  parameters:
vb@2376
    40
//      src (in)        string to duplicate
vb@2376
    41
//      len (in)        length of newly created string or 0 for default
vb@2376
    42
//
vb@2376
    43
//  return value:
vb@2376
    44
//      pointer to copy or NULL if out of memory
vb@2376
    45
vb@2376
    46
DYNAMIC_API char * string_dup(const char *src, size_t len);
vb@2376
    47
vb@2376
    48
vb@2376
    49
#ifdef __cplusplus
vb@2376
    50
}
vb@2376
    51
#endif
vb@2376
    52