diff options
Diffstat (limited to 'stringbuf.c')
-rwxr-xr-x | stringbuf.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/stringbuf.c b/stringbuf.c index 11a1f5e4..0c5493d0 100755 --- a/stringbuf.c +++ b/stringbuf.c @@ -136,6 +136,7 @@ srRetVal rsCStrAppendChar(rsCStrObj *pThis, char c) char* rsCStrConvSzStrAndDestruct(rsCStrObj *pThis) { char* pRetBuf; + int i; sbSTRBCHECKVALIDOBJECT(pThis); @@ -153,6 +154,16 @@ char* rsCStrConvSzStrAndDestruct(rsCStrObj *pThis) *(pThis->pszBuf + pThis->iStrLen) = '\0'; } } + /* we now need to do a sanity check. The string mgiht contain a + * \0 byte. There is no way how a sz string can handle this. For + * the time being, we simply replace it with space - something that + * could definitely be improved (TODO). + * 2005-09-09 rgerhards + */ + for(i = 0 ; i < pThis->iStrLen ; ++i) { + if(*(pThis->pszBuf + i) == '\0') + *(pThis->pszBuf + i) = ' '; + } /* We got it, now free the object ourselfs. Please note * that we can NOT use the rsCStrDestruct function as it would @@ -202,6 +213,15 @@ void rsCStrSetAllocIncrement(rsCStrObj *pThis, int iNewIncrement) pThis->iAllocIncrement = iNewIncrement; } +/* return the length of the current string + * 2005-09-09 rgerhards + */ +int rsCStrLen(rsCStrObj *pThis) +{ + sbSTRBCHECKVALIDOBJECT(pThis); + return(pThis->iStrLen); +} + /* * Local variables: * c-indent-level: 8 |