src/pEp_string.h
author Krista Bennett <krista@pep-project.org>
Fri, 04 May 2018 16:30:21 +0200
branchlocal_cpptest
changeset 2652 43b913f99a27
parent 2440 3c45fce3ef40
permissions -rw-r--r--
Shelving broken things to break other things
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@2378
    23
//  calling with str and len is equivalent to strndup()
vb@2378
    24
//  calling with str but len=0 is equivalent to strdup()
vb@2440
    25
//  calling with str=NULL is equivalent to calloc()
vb@2376
    26
vb@2376
    27
DYNAMIC_API char * new_string(const char *src, size_t len);
vb@2376
    28
vb@2376
    29
vb@2376
    30
// free_string() - free memory occupied by string
vb@2376
    31
//
vb@2376
    32
//  parameters:
vb@2377
    33
//      s (in)          pointer to string to free
vb@2376
    34
vb@2376
    35
DYNAMIC_API void free_string(char *s);
vb@2376
    36
vb@2376
    37
vb@2376
    38
// string_dup() - duplicate a string
vb@2376
    39
//
vb@2376
    40
//  parameters:
vb@2376
    41
//      src (in)        string to duplicate
vb@2376
    42
//      len (in)        length of newly created string or 0 for default
vb@2376
    43
//
vb@2376
    44
//  return value:
vb@2376
    45
//      pointer to copy or NULL if out of memory
vb@2376
    46
vb@2376
    47
DYNAMIC_API char * string_dup(const char *src, size_t len);
vb@2376
    48
vb@2376
    49
vb@2376
    50
#ifdef __cplusplus
vb@2376
    51
}
vb@2376
    52
#endif
vb@2376
    53