comparison src/xs_support.c @ 224:df4cb5115322

Removed duplicate function, more portability cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 15 Dec 2004 14:23:03 +0000
parents 57231fe14369
children 858c09f59011
comparison
equal deleted inserted replaced
223:16e3b2446a73 224:df4cb5115322
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */ 21 */
22 #include "xmms-sid.h" 22 #include "xmms-sid.h"
23 #include "xs_support.h" 23 #include "xs_support.h"
24 24 #include <ctype.h>
25 25
26 /* Copy a string 26 /* Copy a string
27 */ 27 */
28 gchar *xs_strncpy(gchar *pDest, gchar *pSource, size_t n) 28 gchar *xs_strncpy(gchar *pDest, gchar *pSource, size_t n)
29 { 29 {
73 /* Check the string pointers */ 73 /* Check the string pointers */
74 if (!ppResult || !pStr) return -1; 74 if (!ppResult || !pStr) return -1;
75 75
76 if (*ppResult != NULL) 76 if (*ppResult != NULL)
77 { 77 {
78 *ppResult = g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1); 78 *ppResult = (gchar *) g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1);
79 if (*ppResult == NULL) return -1; 79 if (*ppResult == NULL) return -1;
80
81 strcat(*ppResult, pStr); 80 strcat(*ppResult, pStr);
82 } else 81 } else
83 { 82 {
84 *ppResult = g_malloc(strlen(pStr) + 1); 83 *ppResult = (gchar *) g_malloc(strlen(pStr) + 1);
85 if (*ppResult == NULL) return -1; 84 if (*ppResult == NULL) return -1;
86
87 strcpy(*ppResult, pStr); 85 strcpy(*ppResult, pStr);
88 } 86 }
89 87
90 return 0; 88 return 0;
91 } 89 }