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

Side by Side Diff: swig/Lib/typemaps/cmalloc.swg

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « swig/Lib/typemaps/cdata.swg ('k') | swig/Lib/typemaps/cpointer.swg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4 *
5 * cmalloc.swg
6 *
7 * This library file contains macros that can be used to create objects using
8 * the C malloc function.
9 * ----------------------------------------------------------------------------- */
10
11 %{
12 #include <stdlib.h>
13 %}
14
15 /* %malloc(TYPE [, NAME = TYPE])
16 %calloc(TYPE [, NAME = TYPE])
17 %realloc(TYPE [, NAME = TYPE])
18 %free(TYPE [, NAME = TYPE])
19 %allocators(TYPE [,NAME = TYPE])
20
21 Creates functions for allocating/reallocating memory.
22
23 TYPE *malloc_NAME(size_t nbytes = sizeof(TYPE);
24 TYPE *calloc_NAME(size_t nobj=1, size_t size=sizeof(TYPE));
25 TYPE *realloc_NAME(TYPE *ptr, size_t nbytes);
26 void free_NAME(TYPE *ptr);
27
28 */
29
30 %define %malloc(TYPE,NAME...)
31 #if #NAME != ""
32 %rename(malloc_##NAME) ::malloc(size_t nbytes);
33 #else
34 %rename(malloc_##TYPE) ::malloc(size_t nbytes);
35 #endif
36
37 #if #TYPE != "void"
38 %typemap(default) size_t nbytes "$1 = (size_t) sizeof(TYPE);"
39 #endif
40 TYPE *malloc(size_t nbytes);
41 %typemap(default) size_t nbytes;
42 %enddef
43
44 %define %calloc(TYPE,NAME...)
45 #if #NAME != ""
46 %rename(calloc_##NAME) ::calloc(size_t nobj, size_t sz);
47 #else
48 %rename(calloc_##TYPE) ::calloc(size_t nobj, size_t sz);
49 #endif
50 #if #TYPE != "void"
51 %typemap(default) size_t sz "$1 = (size_t) sizeof(TYPE);"
52 #else
53 %typemap(default) size_t sz "$1 = 1;"
54 #endif
55 %typemap(default) size_t nobj "$1 = 1;"
56 TYPE *calloc(size_t nobj, size_t sz);
57 %typemap(default) size_t sz;
58 %typemap(default) size_t nobj;
59 %enddef
60
61 %define %realloc(TYPE,NAME...)
62 %insert("header") {
63 #if #NAME != ""
64 TYPE *realloc_##NAME(TYPE *ptr, size_t nitems)
65 #else
66 TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems)
67 #endif
68 {
69 #if #TYPE != "void"
70 return (TYPE *) realloc(ptr, nitems*sizeof(TYPE));
71 #else
72 return (TYPE *) realloc(ptr, nitems);
73 #endif
74 }
75 }
76 #if #NAME != ""
77 TYPE *realloc_##NAME(TYPE *ptr, size_t nitems);
78 #else
79 TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems);
80 #endif
81 %enddef
82
83 %define %free(TYPE,NAME...)
84 #if #NAME != ""
85 %rename(free_##NAME) ::free(TYPE *ptr);
86 #else
87 %rename(free_##TYPE) ::free(TYPE *ptr);
88 #endif
89 void free(TYPE *ptr);
90 %enddef
91
92 %define %sizeof(TYPE,NAME...)
93 #if #NAME != ""
94 %constant size_t sizeof_##NAME = sizeof(TYPE);
95 #else
96 %constant size_t sizeof_##TYPE = sizeof(TYPE);
97 #endif
98 %enddef
99
100 %define %allocators(TYPE,NAME...)
101 %malloc(TYPE,NAME)
102 %calloc(TYPE,NAME)
103 %realloc(TYPE,NAME)
104 %free(TYPE,NAME)
105 #if #TYPE != "void"
106 %sizeof(TYPE,NAME)
107 #endif
108 %enddef
109
110
111
112
113
OLDNEW
« no previous file with comments | « swig/Lib/typemaps/cdata.swg ('k') | swig/Lib/typemaps/cpointer.swg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698