summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/m_memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/m_memory.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/m_memory.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/apps/plugins/pdbox/PDa/src/m_memory.c b/apps/plugins/pdbox/PDa/src/m_memory.c
index 085154299b..ef33d3c1d3 100644
--- a/apps/plugins/pdbox/PDa/src/m_memory.c
+++ b/apps/plugins/pdbox/PDa/src/m_memory.c
@@ -87,92 +87,4 @@ void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
87 fprintf(stderr, "total mem %d\n", totalmem); 87 fprintf(stderr, "total mem %d\n", totalmem);
88} 88}
89#endif 89#endif
90/* Copyright (c) 1997-1999 Miller Puckette.
91* For information on usage and redistribution, and for a DISCLAIMER OF ALL
92* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
93
94#include <stdlib.h>
95#include <string.h>
96#include "m_pd.h"
97#include "m_imp.h"
98
99/* #define LOUD */
100#ifdef LOUD
101#include <stdio.h>
102#endif
103
104/* #define DEBUGMEM */
105#ifdef DEBUGMEM
106static int totalmem = 0;
107#endif
108
109void *getbytes(size_t nbytes)
110{
111 void *ret;
112 if (nbytes < 1) nbytes = 1;
113 ret = (void *)calloc(nbytes, 1);
114#ifdef LOUD
115 fprintf(stderr, "new %x %d\n", (int)ret, nbytes);
116#endif /* LOUD */
117#ifdef DEBUGMEM
118 totalmem += nbytes;
119#endif
120 if (!ret)
121 post("pd: getbytes() failed -- out of memory");
122 return (ret);
123}
124
125void *getzbytes(size_t nbytes) /* obsolete name */
126{
127 return (getbytes(nbytes));
128}
129
130void *copybytes(void *src, size_t nbytes)
131{
132 void *ret;
133 ret = getbytes(nbytes);
134 if (nbytes)
135 memcpy(ret, src, nbytes);
136 return (ret);
137}
138
139void *resizebytes(void *old, size_t oldsize, size_t newsize)
140{
141 void *ret;
142 if (newsize < 1) newsize = 1;
143 if (oldsize < 1) oldsize = 1;
144 ret = (void *)realloc((char *)old, newsize);
145 if (newsize > oldsize && ret)
146 memset(((char *)ret) + oldsize, 0, newsize - oldsize);
147#ifdef LOUD
148 fprintf(stderr, "resize %x %d --> %x %d\n", (int)old, oldsize, (int)ret, newsize);
149#endif /* LOUD */
150#ifdef DEBUGMEM
151 totalmem += (newsize - oldsize);
152#endif
153 if (!ret)
154 post("pd: resizebytes() failed -- out of memory");
155 return (ret);
156}
157
158void freebytes(void *fatso, size_t nbytes)
159{
160 if (nbytes == 0)
161 nbytes = 1;
162#ifdef LOUD
163 fprintf(stderr, "free %x %d\n", (int)fatso, nbytes);
164#endif /* LOUD */
165#ifdef DEBUGMEM
166 totalmem -= nbytes;
167#endif
168 free(fatso);
169}
170
171#ifdef DEBUGMEM
172#include <stdio.h>
173 90
174void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
175{
176 fprintf(stderr, "total mem %d\n", totalmem);
177}
178#endif