added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / classes / zune / betterstring / mcc / AllocFunctions.c
blob62e603089de4265c86e4d6d885fd378199b7fe87
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005 by BetterString.mcc 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 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
19 $Id$
21 ***************************************************************************/
23 #include <string.h>
25 #include <clib/alib_protos.h>
26 #include <exec/types.h>
27 #include <proto/exec.h>
29 #include "private.h"
31 APTR MyAllocPooled(APTR pool, ULONG length)
33 long *mem;
35 if((mem = AllocPooled(pool, length+4)))
37 *mem = length+4;
38 mem += 1;
40 return(mem);
42 else
43 return(NULL);
46 void MyFreePooled(void *pool, void *mem)
48 long *memptr = (long *)mem;
49 long length;
51 memptr -= 1;
52 length = *(memptr);
54 FreePooled(pool, memptr, length);
57 APTR ExpandPool(APTR pool, APTR mem, ULONG extra)
59 ULONG length;
61 length = *(((ULONG *)mem)-1);
62 if(length <= strlen((STRPTR)mem)+extra+4)
64 APTR new_mem;
68 new_mem = MyAllocPooled(pool, strlen((STRPTR)mem)+extra+20);
70 while(!new_mem);
72 CopyMem(mem, new_mem, length);
73 MyFreePooled(pool, mem);
74 mem = new_mem;
77 return(mem);