1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef INCLUDED_I18NUTIL_X_RTL_USTRING_H
24 #define INCLUDED_I18NUTIL_X_RTL_USTRING_H
25 
26 #ifndef _RTL_STRING_HXX_
27 #include <rtl/strbuf.hxx>
28 #endif
29 #include <rtl/memory.h>
30 #include <rtl/alloc.h>
31 
32 
33 /**
34  * Allocates a new <code>rtl_uString</code> which can hold nLen + 1 characters.
35  * The reference count is 1. The memory allocated for the characters is not initialized.
36  * @param	[input]  nLen
37  */
x_rtl_uString_new_WithLength(sal_Int32 nLen)38 inline rtl_uString * SAL_CALL x_rtl_uString_new_WithLength( sal_Int32 nLen )
39 {
40   rtl_uString *newStr = (rtl_uString*) rtl_allocateMemory ( sizeof(rtl_uString) + sizeof(sal_Unicode) * nLen);
41   newStr->refCount = 1;
42   newStr->length = nLen;
43   return newStr;
44 
45   // rtl_uString is defined in rtl/ustring.h as below:
46   //typedef struct _rtl_uString
47   //{
48   //    sal_Int32		refCount;
49   //	sal_Int32		length;
50   //	sal_Unicode 	buffer[1];
51   //} rtl_uString;
52 }
53 
54 /**
55  * Release <code>rtl_uString</code> regardless its reference count.
56  */
x_rtl_uString_release(rtl_uString * value)57 inline void SAL_CALL x_rtl_uString_release( rtl_uString * value )
58 {
59   rtl_freeMemory(value);
60 }
61 
62 
63 #endif // #ifndef _I18N_X_RTL_USTRING_H_
64