00001 /***************************************************************************** 00002 * xstrcat.h: strcat with realloc 00003 ***************************************************************************** 00004 * Copyright (C) 2004 Commonwealth Scientific and Industrial Research 00005 * Organisation (CSIRO) Australia 00006 * Copyright (C) 2004 the VideoLAN team 00007 * 00008 * $Id$ 00009 * 00010 * Authors: Andre Pang <Andre.Pang@csiro.au> 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU General Public License 00023 * along with this program; if not, write to the Free Software 00024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00025 *****************************************************************************/ 00026 00027 #ifndef __XSTRCAT_H__ 00028 #define __XSTRCAT_H__ 00029 # include <string.h> 00030 # include <stdlib.h> 00031 00032 /* like strcat, but realloc's enough memory for the new string too */ 00033 00034 static inline 00035 char *xstrcat( char *psz_string, const char *psz_to_append ) 00036 { 00037 size_t i_new_string_length = strlen( psz_string ) + 00038 strlen( psz_to_append ) + 1; 00039 00040 psz_string = (char *) realloc( psz_string, i_new_string_length ); 00041 00042 return strcat( psz_string, psz_to_append ); 00043 } 00044 00045 #endif /* __XSTRCAT_H__ */ 00046
1.5.6