Updated from its repository.
[cake.git] / workbench / classes / gadgets / texteditor / mcc / AllocFunctions.c
blobb1ea34d8c8329bfdbe34d18fc7bdefed644bacb4
1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2009 by TextEditor.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 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
19 $Id$
21 ***************************************************************************/
23 #include <proto/exec.h>
25 #include "private.h"
27 #include "Debug.h"
29 APTR MyAllocPooled(APTR pool, ULONG length)
31 ULONG *mem;
33 ENTER();
35 length += sizeof(ULONG);
36 if((mem = AllocPooled(pool, length)))
38 *mem = length;
39 mem += 1;
42 RETURN(mem);
43 return(mem);
46 VOID MyFreePooled(APTR pool, APTR mem)
48 ULONG *memptr, length;
50 ENTER();
52 memptr = &((ULONG *)mem)[-1];
53 length = *memptr;
55 FreePooled(pool, memptr, length);
57 LEAVE();
60 struct line_node *AllocLine(struct InstData *data)
62 struct line_node *newline;
64 ENTER();
66 newline = AllocPooled(data->mypool, sizeof(struct line_node));
68 RETURN(newline);
69 return newline;
72 void FreeLine(struct line_node* line, struct InstData *data)
74 ENTER();
76 // we make sure the line is not references by other
77 // structures as well such as the global blockinfo structure.
78 if(data->blockinfo.startline == line)
80 if(line->next)
81 data->blockinfo.startline = line->next;
82 else
84 data->blockinfo.startline = NULL;
85 data->blockinfo.enabled = FALSE;
89 if(data->blockinfo.stopline == line)
91 if(line->previous)
92 data->blockinfo.stopline = line->previous;
93 else
95 data->blockinfo.stopline = NULL;
96 data->blockinfo.enabled = FALSE;
100 // lets use FreePooled to free the memory of the line
101 FreePooled(data->mypool, line, sizeof(struct line_node));
103 LEAVE();