1 /* Hardware memory allocator.
2 Copyright (C) 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program 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
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
30 struct hw_alloc_data {
33 struct hw_alloc_data *next;
37 create_hw_alloc_data (struct hw *me)
43 delete_hw_alloc_data (struct hw *me)
45 if (me->alloc_of_hw != NULL)
46 hw_abort (me, "hw-alloc botch");
47 while (me->alloc_of_hw != NULL)
49 hw_free (me, me->alloc_of_hw->alloc);
56 hw_zalloc (struct hw *me, unsigned long size)
58 struct hw_alloc_data *memory = ZALLOC (struct hw_alloc_data);
59 memory->alloc = zalloc (size);
61 memory->next = me->alloc_of_hw;
62 me->alloc_of_hw = memory;
67 hw_malloc (struct hw *me, unsigned long size)
69 struct hw_alloc_data *memory = ZALLOC (struct hw_alloc_data);
70 memory->alloc = zalloc (size);
72 memory->next = me->alloc_of_hw;
73 me->alloc_of_hw = memory;
78 hw_free (struct hw *me,
81 struct hw_alloc_data **memory;
82 for (memory = &me->alloc_of_hw;
84 memory = &(*memory)->next)
86 if ((*memory)->alloc == alloc)
88 struct hw_alloc_data *die = (*memory);
89 (*memory) = die->next;
98 hw_abort (me, "free of memory not belonging to a device");