1 /***************************************************************************
3 codesets.library - Amiga shared library for handling different codesets
4 Copyright (C) 2001-2005 by Alfonso [alfie] Ranieri <alforan@tin.it>.
5 Copyright (C) 2005-2009 by codesets.library Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 codesets.library project: http://sourceforge.net/projects/codesetslib/
21 ***************************************************************************/
26 /****************************************************************************/
28 #if !defined(HAVE_ALLOCVECPOOLED)
30 allocVecPooled(APTR pool
,ULONG size
)
36 size
+= sizeof(ULONG
);
37 if((mem
= AllocPooled(pool
, size
)))
45 /****************************************************************************/
47 #if !defined(HAVE_FREEVECPOOLED)
49 freeVecPooled(APTR pool
,APTR mem
)
53 FreePooled(pool
,(LONG
*)mem
- 1,*((LONG
*)mem
- 1));
59 /****************************************************************************/
62 reallocVecPooled(APTR pool
, APTR mem
, ULONG oldSize
, ULONG newSize
)
68 if((newMem
= allocVecPooled(pool
, newSize
)) != NULL
)
70 memcpy(newMem
, mem
, (oldSize
< newSize
) ? oldSize
: newSize
);
72 freeVecPooled(pool
, mem
);
79 /****************************************************************************/
82 allocArbitrateVecPooled(ULONG size
)
88 ObtainSemaphore(&CodesetsBase
->poolSem
);
89 mem
= allocVecPooled(CodesetsBase
->pool
, size
);
90 ReleaseSemaphore(&CodesetsBase
->poolSem
);
96 /****************************************************************************/
99 freeArbitrateVecPooled(APTR mem
)
103 ObtainSemaphore(&CodesetsBase
->poolSem
);
104 freeVecPooled(CodesetsBase
->pool
, mem
);
105 ReleaseSemaphore(&CodesetsBase
->poolSem
);
110 /****************************************************************************/
113 reallocArbitrateVecPooled(APTR mem
, ULONG oldSize
, ULONG newSize
)
117 ObtainSemaphore(&CodesetsBase
->poolSem
);
118 mem
= reallocVecPooled(CodesetsBase
->pool
, mem
, oldSize
, newSize
);
119 ReleaseSemaphore(&CodesetsBase
->poolSem
);
125 /****************************************************************************/
127 ULONG
utf16_strlen(UTF16
*ptr
)
131 for (l
=0; ptr
[l
]; l
++);
135 /****************************************************************************/
137 ULONG
utf32_strlen(UTF32
*ptr
)
141 for (l
=0; ptr
[l
]; l
++);