OLD | NEW |
1 /* | 1 /* |
2 * alloc.c | 2 * alloc.c |
3 * | 3 * |
4 * memory allocation and deallocation | 4 * memory allocation and deallocation |
5 * | 5 * |
6 * David A. McGrew | 6 * David A. McGrew |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 */ | 8 */ |
9 /* | 9 /* |
10 * | 10 * |
(...skipping 24 matching lines...) Expand all Loading... |
35 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 35 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
41 * OF THE POSSIBILITY OF SUCH DAMAGE. | 41 * OF THE POSSIBILITY OF SUCH DAMAGE. |
42 * | 42 * |
43 */ | 43 */ |
44 | 44 |
| 45 #ifdef HAVE_CONFIG_H |
| 46 #include <config.h> |
| 47 #endif |
| 48 |
45 #include "alloc.h" | 49 #include "alloc.h" |
46 #include "crypto_kernel.h" | 50 #include "crypto_kernel.h" |
47 | 51 |
48 /* the debug module for memory allocation */ | 52 /* the debug module for memory allocation */ |
49 | 53 |
50 debug_module_t mod_alloc = { | 54 debug_module_t mod_alloc = { |
51 0, /* debugging is off by default */ | 55 0, /* debugging is off by default */ |
52 "alloc" /* printable name for module */ | 56 "alloc" /* printable name for module */ |
53 }; | 57 }; |
54 | 58 |
(...skipping 11 matching lines...) Expand all Loading... |
66 #include <linux/interrupt.h> | 70 #include <linux/interrupt.h> |
67 | 71 |
68 void * | 72 void * |
69 crypto_alloc(size_t size) { | 73 crypto_alloc(size_t size) { |
70 void *ptr; | 74 void *ptr; |
71 | 75 |
72 ptr = kmalloc(size, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 76 ptr = kmalloc(size, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
73 | 77 |
74 if (ptr) { | 78 if (ptr) { |
75 debug_print(mod_alloc, "(location: %p) allocated", ptr); | 79 debug_print(mod_alloc, "(location: %p) allocated", ptr); |
76 } else | 80 } else { |
77 debug_print(mod_alloc, "allocation failed (asked for %d bytes)\n", size); | 81 debug_print(mod_alloc, "allocation failed (asked for %d bytes)\n", size); |
| 82 } |
78 | 83 |
79 return ptr; | 84 return ptr; |
80 } | 85 } |
81 | 86 |
82 void | 87 void |
83 crypto_free(void *ptr) { | 88 crypto_free(void *ptr) { |
84 | 89 |
85 debug_print(mod_alloc, "(location: %p) freed", ptr); | 90 debug_print(mod_alloc, "(location: %p) freed", ptr); |
86 | 91 |
87 kfree(ptr); | 92 kfree(ptr); |
(...skipping 22 matching lines...) Expand all Loading... |
110 debug_print(mod_alloc, "(location: %p) freed", ptr); | 115 debug_print(mod_alloc, "(location: %p) freed", ptr); |
111 | 116 |
112 free(ptr); | 117 free(ptr); |
113 } | 118 } |
114 | 119 |
115 #else /* we need to define our own memory allocation routines */ | 120 #else /* we need to define our own memory allocation routines */ |
116 | 121 |
117 #error no memory allocation defined yet | 122 #error no memory allocation defined yet |
118 | 123 |
119 #endif | 124 #endif |
OLD | NEW |