]> git.sesse.net Git - vlc/blob - modules/codec/cmml/xstrcat.h
Removes trailing spaces. Removes tabs.
[vlc] / modules / codec / cmml / xstrcat.h
1 /*****************************************************************************
2  * xstrcat.h: strcat with realloc
3  *****************************************************************************
4  * Copyright (C) 2004 Commonwealth Scientific and Industrial Research
5  *                    Organisation (CSIRO) Australia
6  * Copyright (C) 2004 the VideoLAN team
7  *
8  * $Id$
9  *
10  * Authors: Andre Pang <Andre.Pang@csiro.au>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 #ifndef __XSTRCAT_H__
28 #define __XSTRCAT_H__
29 # include <string.h>
30 # include <stdlib.h>
31
32 /* like strcat, but realloc's enough memory for the new string too */
33
34 static inline
35 char *xstrcat( char *psz_string, const char *psz_to_append )
36 {
37     size_t i_new_string_length = strlen( psz_string ) +
38         strlen( psz_to_append ) + 1;
39
40     psz_string = (char *) realloc( psz_string, i_new_string_length );
41
42     return strcat( psz_string, psz_to_append );
43 }
44
45 #endif /* __XSTRCAT_H__ */
46