changeset 38:dec37e16136e

Minor changes
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 19 Jun 2003 20:48:04 +0000
parents 5379205b74dd
children 85a7753e2a9a
files src/xs_support.c src/xs_support.h
diffstat 2 files changed, 37 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_support.c	Thu Jun 19 20:16:03 2003 +0000
+++ b/src/xs_support.c	Thu Jun 19 20:48:04 2003 +0000
@@ -28,67 +28,58 @@
 /*
  * Utility routines
  */
-int xs_strcalloc(gchar **result, const gchar *str)
+gint xs_strcalloc(gchar **ppcResult, const gchar *pcStr)
 {
-	/* Check the string pointers */
-	if ((result == NULL) || (str == NULL))
-		return -1;
+ assert(ppcResult);
+ assert(pcStr);
+ 
+ /* Allocate memory for destination */
+ *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(pcStr) + 1);
+ if (*ppResult == NULL) return -1;
 
-	/* Allocate memory for destination */
-	*result = (gchar *) g_realloc(*result, strlen(str) + 1);
-
-	if (*result == NULL) return -2;
+ /* Copy to the destination */
+ strcpy(*ppcResult, pcStr);
 
-	/* Copy to the destination */
-	strcpy(*result, str);
-	
-	return 0;
+ return 0;
 }
 
 
 int xs_strcat(gchar **ppcResult, const gchar *pcStr)
 {
-	int ilen;
-
-	/* Check the pcString pointers */
-	if ((ppcResult == NULL) || (pcStr == NULL))
-		return -1;
-
-	/* Get length of the pcString to be catted */
-	ilen = strlen(pcStr);
+ assert(ppcResult);
+ assert(pcStr);
+ 
+ /* Re-allocate memory for destination */
+ *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + strlen(pcStr) + 1);
+ if (*ppcResult == NULL) return -1;
 
-	/* Re-allocate memory for destination */
-	*ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + ilen + 1);
-
-	if (*ppcResult == NULL) return -2;
+ /* Cat to the destination */
+ strcat(*ppcResult, pcStr);
 
-	/* Cat to the destination */
-	strcat(*ppcResult, pcStr);
-
-	return 0;
+ return 0;
 }
 
 
-int xs_strcpy(gchar **ppcResult, gint *j, const gchar *pcStr)
+int xs_strpcat(gchar **ppcResult, gint *j, const gchar *pcStr)
 {
-	int ilen;
-
-	/* Check the pcString pointers */
-	if ((ppcResult == NULL) || (pcStr == NULL) || (j == NULL))
-		return -1;
+ int iLen;
 
-	/* Get length of the pcString to be catted */
-	(*j) += ilen = strlen(pcStr);
-
-	/* Re-allocate memory for destination */
-	*ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + ilen + 1);
+ assert(ppcResult);
+ assert(pcStr);
+ assert(j);
+ 
+ /* Get length of the pcString to be catted */
+ iLen = strlen(pcStr);
+ (*j) += iLen;
 
-	if (*ppcResult == NULL) return -2;
+ /* Re-allocate memory for destination */
+ *ppcResult = (gchar *) g_realloc(*ppcResult, strlen(*ppcResult) + iLen + 1);
+ if (*ppcResult == NULL) return -1;
 
-	/* Cat to the destination */
-	strcat(*ppcResult, pcStr);
+ /* Cat to the destination */
+ strcat(*ppcResult, pcStr);
 
-	return 0;
+ return 0;
 }
 
 
--- a/src/xs_support.h	Thu Jun 19 20:16:03 2003 +0000
+++ b/src/xs_support.h	Thu Jun 19 20:48:04 2003 +0000
@@ -10,9 +10,9 @@
 /*
  * Functions
  */
-int	xs_strcalloc(gchar **, const gchar *);
-int	xs_strcat(gchar **, const gchar *);
-int	xs_strcpy(gchar **, gint *, const gchar *);
+gint	xs_strcalloc(gchar **, const gchar *);
+gint	xs_strcat(gchar **, const gchar *);
+gint	xs_strpcat(gchar **, gint *, const gchar *);
 inline 	void xs_findnext(gchar *, gint *);
 inline	void xs_findnum(gchar *, gint *);