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