src/pEp_string.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 30 Jun 2020 14:56:25 +0200
branchdoxygen_doc
changeset 4792 7056435ab9e7
parent 2440 3c45fce3ef40
child 5015 fd39cb7d93eb
permissions -rw-r--r--
some doxygen stuff. might not be kept.
krista@4792
     1
/** @file */
krista@4792
     2
/** @brief File description for doxygen missing. FIXME */
krista@4792
     3
vb@2376
     4
// This file is under GNU General Public License 3.0
vb@2376
     5
// see LICENSE.txt
vb@2376
     6
vb@2376
     7
#pragma once
vb@2376
     8
vb@2376
     9
#include <string.h>
vb@2376
    10
#include "dynamic_api.h"
vb@2376
    11
vb@2376
    12
#ifdef __cplusplus
vb@2376
    13
extern "C" {
vb@2376
    14
#endif
vb@2376
    15
vb@2376
    16
vb@2376
    17
// new_string() - allocate a new string
vb@2376
    18
//
vb@2376
    19
//  parameters:
vb@2376
    20
//      src (in)        string to copy or NULL
vb@2376
    21
//      len (in)        length of newly created string or 0 for default
vb@2376
    22
//
vb@2376
    23
//  return value:
vb@2376
    24
//      pointer to string object or NULL if out of memory
vb@2376
    25
//
vb@2378
    26
//  calling with str and len is equivalent to strndup()
vb@2378
    27
//  calling with str but len=0 is equivalent to strdup()
vb@2440
    28
//  calling with str=NULL is equivalent to calloc()
vb@2376
    29
vb@2376
    30
DYNAMIC_API char * new_string(const char *src, size_t len);
vb@2376
    31
vb@2376
    32
vb@2376
    33
// free_string() - free memory occupied by string
vb@2376
    34
//
vb@2376
    35
//  parameters:
vb@2377
    36
//      s (in)          pointer to string to free
vb@2376
    37
vb@2376
    38
DYNAMIC_API void free_string(char *s);
vb@2376
    39
vb@2376
    40
vb@2376
    41
// string_dup() - duplicate a string
vb@2376
    42
//
vb@2376
    43
//  parameters:
vb@2376
    44
//      src (in)        string to duplicate
vb@2376
    45
//      len (in)        length of newly created string or 0 for default
vb@2376
    46
//
vb@2376
    47
//  return value:
vb@2376
    48
//      pointer to copy or NULL if out of memory
vb@2376
    49
vb@2376
    50
DYNAMIC_API char * string_dup(const char *src, size_t len);
vb@2376
    51
vb@2376
    52
vb@2376
    53
#ifdef __cplusplus
vb@2376
    54
}
vb@2376
    55
#endif
vb@2376
    56