add casts to zune macros to silence some warnings
[tangerine.git] / workbench / libs / codesetslib / src / utils.c
blob38a69357552bb4a907eba7d7590b8b3ea7b8f5e6
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-2007 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/
19 $Id$
21 ***************************************************************************/
23 #include "lib.h"
25 /****************************************************************************/
27 APTR
28 allocVecPooled(APTR pool,ULONG size)
30 ULONG *mem;
32 if((mem = AllocPooled(pool,size += sizeof(ULONG))))
33 *mem++ = size;
35 return mem;
38 /****************************************************************************/
40 void
41 freeVecPooled(APTR pool,APTR mem)
43 FreePooled(pool,(LONG *)mem - 1,*((LONG *)mem - 1));
46 /****************************************************************************/
48 APTR
49 allocArbitratePooled(ULONG s)
51 APTR mem;
53 ObtainSemaphore(&CodesetsBase->poolSem);
54 mem = AllocPooled(CodesetsBase->pool, s);
55 ReleaseSemaphore(&CodesetsBase->poolSem);
57 return mem;
60 /****************************************************************************/
62 void
63 freeArbitratePooled(APTR mem,ULONG s)
65 ObtainSemaphore(&CodesetsBase->poolSem);
66 FreePooled(CodesetsBase->pool, mem, s);
67 ReleaseSemaphore(&CodesetsBase->poolSem);
70 /****************************************************************************/
72 APTR
73 allocArbitrateVecPooled(ULONG size)
75 ULONG *mem;
77 ObtainSemaphore(&CodesetsBase->poolSem);
78 mem = allocVecPooled(CodesetsBase->pool, size);
79 ReleaseSemaphore(&CodesetsBase->poolSem);
81 return mem;
84 /****************************************************************************/
86 void
87 freeArbitrateVecPooled(APTR mem)
89 ObtainSemaphore(&CodesetsBase->poolSem);
90 freeVecPooled(CodesetsBase->pool, mem);
91 ReleaseSemaphore(&CodesetsBase->poolSem);
94 /****************************************************************************/