* eCos->devo merge; am30 sanitization tags removed
[deliverable/binutils-gdb.git] / mmalloc / keys.c
1 /* Access for application keys in mmap'd malloc managed region.
2 Copyright 1992 Free Software Foundation, Inc.
3
4 Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21 /* This module provides access to some keys that the application can use to
22 provide persistent access to locations in the mapped memory section.
23 The intent is that these keys are to be used sparingly as sort of
24 persistent global variables which the application can use to reinitialize
25 access to data in the mapped region.
26
27 For the moment, these keys are simply stored in the malloc descriptor
28 itself, in an array of fixed length. This should be fixed so that there
29 can be an unlimited number of keys, possibly using a multilevel access
30 scheme of some sort. */
31
32 #include "mmalloc.h"
33
34 int
35 mmalloc_setkey (md, keynum, key)
36 PTR md;
37 int keynum;
38 PTR key;
39 {
40 struct mdesc *mdp = (struct mdesc *) md;
41 int result = 0;
42
43 if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
44 {
45 mdp -> keys [keynum] = key;
46 result++;
47 }
48 return (result);
49 }
50
51 PTR
52 mmalloc_getkey (md, keynum)
53 PTR md;
54 int keynum;
55 {
56 struct mdesc *mdp = (struct mdesc *) md;
57 PTR keyval = NULL;
58
59 if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
60 {
61 keyval = mdp -> keys [keynum];
62 }
63 return (keyval);
64 }
This page took 0.031762 seconds and 4 git commands to generate.