# HG changeset patch # User Matti Hamalainen # Date 1056055684 0 # Node ID dec37e16136e9b50bb318ced40e552ec22880d8c # Parent 5379205b74ddff10017d4edbc4f10101a17bd100 Minor changes diff -r 5379205b74dd -r dec37e16136e src/xs_support.c --- 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; } diff -r 5379205b74dd -r dec37e16136e src/xs_support.h --- 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 *);