diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-06-30 09:12:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-06-30 11:35:56 +0100 |
commit | 1a2912eed9980d7ded481bc60a81597b0c699481 (patch) | |
tree | 6528508c2e04c31345ad1a4392638b118b561b40 /sal/rtl/source/strbuf.c | |
parent | 4312ed8c4f85575ab125da84ba09f02430ee9a89 (diff) |
add StringBuffers ::remove
Diffstat (limited to 'sal/rtl/source/strbuf.c')
-rw-r--r-- | sal/rtl/source/strbuf.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sal/rtl/source/strbuf.c b/sal/rtl/source/strbuf.c index 47fd5c8b51ed..a620a3c0419d 100644 --- a/sal/rtl/source/strbuf.c +++ b/sal/rtl/source/strbuf.c @@ -146,4 +146,37 @@ void SAL_CALL rtl_stringbuffer_insert( rtl_String ** This, } } +/************************************************************************* + * rtl_stringbuffer_remove + */ +void SAL_CALL rtl_stringbuffer_remove( rtl_String ** This, + sal_Int32 start, + sal_Int32 end ) +{ + sal_Int32 nTailLen; + sal_Char * pBuf; + sal_Int32 n; + + if (end > (*This)->length) + end = (*This)->length; + + n = end - start; + + //remove nothing + if (!n) + return; + + pBuf = (*This)->buffer; + nTailLen = (*This)->length - end; + + if (nTailLen) + { + /* move the tail */ + rtl_moveMemory(pBuf + start, pBuf + end, nTailLen * sizeof(sal_Char)); + } + + (*This)->length-=n; + pBuf[ (*This)->length ] = 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |