source: git/src/str.h @ 77cdf30

walls-datawalls-data-hanging-as-warning
Last change on this file since 77cdf30 was ab7cded, checked in by Olly Betts <olly@…>, 2 months ago

Expand macros

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/* append a string */
2/* Copyright (c) Olly Betts 1999, 2001, 2012, 2014
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19#include "osalloc.h"
20
21void s_cat(char **pstr, int *plen, const char *s);
22
23void s_catlen(char **pstr, int *plen, const char *s, int s_len);
24
25/* append a character */
26void s_catchar(char **pstr, int *plen, char /*ch*/);
27
28/* append n copies of a character */
29void s_catn(char **pstr, int *plen, int n, char /*ch*/);
30
31/* truncate string to zero length */
32#define s_zero(P) do { \
33        char **s_zero__P = (P); \
34        if (*s_zero__P) **s_zero__P = '\0'; \
35    } while (0)
36
37#define s_free(P) do { \
38        char **s_free__P = (P); \
39        if (*s_free__P) { \
40            osfree(*s_free__P); \
41            *s_free__P = NULL; \
42        } \
43    } while (0)
Note: See TracBrowser for help on using the repository browser.