3D-ICE 3.0.0
string_t.c
1/******************************************************************************
2 * This file is part of 3D-ICE, version 3.1.0 . *
3 * *
4 * 3D-ICE is free software: you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free *
6 * Software Foundation, either version 3 of the License, or any later *
7 * version. *
8 * *
9 * 3D-ICE is distributed in the hope that it will be useful, but WITHOUT *
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
12 * more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with 3D-ICE. If not, see <http://www.gnu.org/licenses/>. *
16 * *
17 * Copyright (C) 2021 *
18 * Embedded Systems Laboratory - Ecole Polytechnique Federale de Lausanne *
19 * All Rights Reserved. *
20 * *
21 * Authors: Arvind Sridhar Alessandro Vincenzi *
22 * Giseong Bak Martino Ruggiero *
23 * Thomas Brunschwiler Eder Zulian *
24 * Federico Terraneo Darong Huang *
25 * Luis Costero Marina Zapater *
26 * David Atienza *
27 * *
28 * For any comment, suggestion or request about 3D-ICE, please register and *
29 * write to the mailing list (see http://listes.epfl.ch/doc.cgi?liste=3d-ice) *
30 * Any usage of 3D-ICE for research, commercial or other purposes must be *
31 * properly acknowledged in the resulting products or publications. *
32 * *
33 * EPFL-STI-IEL-ESL Mail : 3d-ice@listes.epfl.ch *
34 * Batiment ELG, ELG 130 (SUBSCRIPTION IS NECESSARY) *
35 * Station 11 *
36 * 1015 Lausanne, Switzerland Url : http://esl.epfl.ch/3d-ice *
37 ******************************************************************************/
38
39#include <string.h> // For the string function strcpy
40#include <stdlib.h> // For the memory function free
41
42#include "string_t.h"
43
44/******************************************************************************/
45
46void string_init (String_t *string)
47{
48 *string = NULL ;
49}
50
51/******************************************************************************/
52
53void string_copy (String_t *dst, String_t *src)
54{
55 string_destroy (dst) ;
56
57 *dst = *src == NULL ? NULL : strdup (*src) ;
58}
59
60/******************************************************************************/
61
62void string_copy_cstr (String_t *dst, char *src)
63{
64 string_destroy (dst) ;
65
66 *dst = strdup (src) ;
67}
68
69/******************************************************************************/
70
71bool string_equal (String_t *string, String_t *other)
72{
73 return strcmp (*string, *other) == 0 ? true : false ;
74}
75
76/******************************************************************************/
77
79{
80 if (*string != NULL)
81
82 free (*string) ;
83
84 string_init (string) ;
85}
86
87/******************************************************************************/
char * String_t
Definition: string_t.h:55
void string_init(String_t *string)
Definition: string_t.c:46
bool string_equal(String_t *string, String_t *other)
Definition: string_t.c:71
void string_destroy(String_t *string)
Definition: string_t.c:78
void string_copy_cstr(String_t *dst, char *src)
Definition: string_t.c:62
void string_copy(String_t *dst, String_t *src)
Definition: string_t.c:53