Skip to content
Snippets Groups Projects
Commit 2e5e6c1c authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

attempt to fix #330: Soundfiler inefficiency (10x memory usage in Purrdata versus Pd-vanilla)

Don't multiply requested memory size by sizeof(char*)
parent 5bfda305
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ void *getbytes(size_t nbytes)
void *ret;
if (nbytes < 1) nbytes = 1;
ret = (void *)calloc(nbytes, sizeof(char*));
ret = (void *)calloc(nbytes, 1);
#ifdef LOUD
fprintf(stderr, "new %lx %d\n", (int)ret, nbytes);
......@@ -55,9 +55,9 @@ void *resizebytes(void *old, size_t oldsize, size_t newsize)
void *ret;
if (newsize < 1) newsize = 1;
if (oldsize < 1) oldsize = 1;
ret = (void *)realloc((char *)old, newsize * sizeof(char*));
ret = (void *)realloc((char *)old, newsize);
if (newsize > oldsize && ret)
memset(((char *)ret) + oldsize, 0, (newsize - oldsize) * sizeof(char*));
memset(((char *)ret) + oldsize, 0, newsize - oldsize);
#ifdef LOUD
fprintf(stderr, "resize %lx %d --> %lx %d\n", (int)old, oldsize, (int)ret, newsize);
#endif /* LOUD */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment