Commit | Line | Data |
---|---|---|
1bbd0b84 | 1 | /* classes: src_files |
2b829bbb | 2 | * Copyright (C) 1995,1997,1998,2000,2001, 2006 Free Software Foundation, Inc. |
0f2d19dd | 3 | * |
73be1d9e | 4 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
5 | * modify it under the terms of the GNU Lesser General Public License |
6 | * as published by the Free Software Foundation; either version 3 of | |
7 | * the License, or (at your option) any later version. | |
c22adbeb | 8 | * |
53befeb7 NJ |
9 | * This library is distributed in the hope that it will be useful, but |
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. | |
c22adbeb | 13 | * |
73be1d9e MV |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library; if not, write to the Free Software | |
53befeb7 NJ |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | * 02110-1301 USA | |
73be1d9e | 18 | */ |
0f2d19dd | 19 | |
1bbd0b84 GB |
20 | |
21 | ||
0f2d19dd | 22 | \f |
dbb605f5 | 23 | #ifdef HAVE_CONFIG_H |
0261dfae RB |
24 | # include <config.h> |
25 | #endif | |
0f2d19dd | 26 | |
a0599745 MD |
27 | #include "libguile/_scm.h" |
28 | #include "libguile/ports.h" | |
29 | #include "libguile/smob.h" | |
20e6290e | 30 | |
a0599745 | 31 | #include "libguile/mallocs.h" |
20e6290e | 32 | |
0f2d19dd | 33 | #ifdef HAVE_MALLOC_H |
95b88819 | 34 | #include <malloc.h> |
0f2d19dd JB |
35 | #endif |
36 | #ifdef HAVE_UNISTD_H | |
95b88819 | 37 | #include <unistd.h> |
0f2d19dd JB |
38 | #endif |
39 | ||
40 | ||
41 | \f | |
92c2555f | 42 | scm_t_bits scm_tc16_malloc; |
0f2d19dd | 43 | |
1cc91f1b | 44 | |
1cc91f1b | 45 | |
0f2d19dd | 46 | static int |
e81d98ec | 47 | malloc_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED) |
0f2d19dd | 48 | { |
b7f3516f | 49 | scm_puts("#<malloc ", port); |
0345e278 | 50 | scm_uintprint (SCM_SMOB_DATA (exp), 16, port); |
b7f3516f | 51 | scm_putc('>', port); |
0f2d19dd JB |
52 | return 1; |
53 | } | |
54 | ||
55 | \f | |
0f2d19dd | 56 | SCM |
1be6b49c | 57 | scm_malloc_obj (size_t n) |
0f2d19dd | 58 | { |
67329a9e | 59 | scm_t_bits mem = n ? (scm_t_bits) scm_gc_malloc (n, "malloc smob") : 0; |
0f2d19dd | 60 | if (n && !mem) |
216eedfc | 61 | return SCM_BOOL_F; |
23a62151 | 62 | SCM_RETURN_NEWSMOB (scm_tc16_malloc, mem); |
0f2d19dd JB |
63 | } |
64 | ||
65 | ||
66 | \f | |
8574d367 | 67 | void |
0f2d19dd | 68 | scm_init_mallocs () |
0f2d19dd | 69 | { |
e841c3e0 | 70 | scm_tc16_malloc = scm_make_smob_type ("malloc", 0); |
e841c3e0 | 71 | scm_set_smob_print (scm_tc16_malloc, malloc_print); |
0f2d19dd | 72 | } |
89e00824 ML |
73 | |
74 | /* | |
75 | Local Variables: | |
76 | c-file-style: "gnu" | |
77 | End: | |
78 | */ |