Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: srtp/crypto/kernel/alloc.c

Issue 889083003: Update libsrtp to upstream 1.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libsrtp@master
Patch Set: Updated to libsrtp 1.5.1 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « srtp/crypto/include/xfm.h ('k') | srtp/crypto/kernel/crypto_kernel.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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);
88 } 93 }
89 94
90 95
91 #elif defined(HAVE_STDLIB_H) 96 #elif defined(HAVE_STDLIB_H)
92 97
93 void * 98 void *
94 crypto_alloc(size_t size) { 99 crypto_alloc(size_t size) {
95 void *ptr; 100 void *ptr;
96 101
97 ptr = malloc(size); 102 ptr = malloc(size);
98 103
99 if (ptr) { 104 if (ptr) {
100 debug_print(mod_alloc, "(location: %p) allocated", ptr); 105 debug_print(mod_alloc, "(location: %p) allocated", ptr);
101 } else 106 } else {
102 debug_print(mod_alloc, "allocation failed (asked for %d bytes)\n", size); 107 debug_print(mod_alloc, "allocation failed (asked for %d bytes)\n", size);
103 108 }
109
104 return ptr; 110 return ptr;
105 } 111 }
106 112
107 void 113 void
108 crypto_free(void *ptr) { 114 crypto_free(void *ptr) {
109 115
110 debug_print(mod_alloc, "(location: %p) freed", ptr); 116 debug_print(mod_alloc, "(location: %p) freed", ptr);
111 117
112 free(ptr); 118 free(ptr);
113 } 119 }
114 120
115 #else /* we need to define our own memory allocation routines */ 121 #else /* we need to define our own memory allocation routines */
116 122
117 #error no memory allocation defined yet 123 #error no memory allocation defined yet
118 124
119 #endif 125 #endif
OLDNEW
« no previous file with comments | « srtp/crypto/include/xfm.h ('k') | srtp/crypto/kernel/crypto_kernel.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698