Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14096
Modified Files:
Tag: devel_0_37
m_memory.c d_soundfile.c
Log Message:
added copyalignedbytes
Index: m_memory.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_memory.c,v
retrieving revision 1.1.1.2.2.5
retrieving revision 1.1.1.2.2.6
diff -C2 -d -r1.1.1.2.2.5 -r1.1.1.2.2.6
*** m_memory.c 10 Oct 2004 22:01:40 -0000 1.1.1.2.2.5
--- m_memory.c 20 Oct 2004 21:28:16 -0000 1.1.1.2.2.6
***************
*** 11,14 ****
--- 11,23 ----
#include "m_simd.h"
+ /* T.Grill - bit alignment for signal vectors (must be a multiple of 8!) */
+ /* if undefined no alignment occurs */
+ #ifdef SIMD_BYTEALIGN
+ #define VECTORALIGNMENT (SIMD_BYTEALIGN*8)
+ #else
+ #define VECTORALIGNMENT 128
+ #endif
+
+
/* #define LOUD */
#ifdef LOUD
***************
*** 27,31 ****
ret = (void *)calloc(nbytes, 1);
#ifdef LOUD
! fprintf(stderr, "new %x %d\n", (int)ret, nbytes);
#endif /* LOUD */
#ifdef DEBUGMEM
--- 36,40 ----
ret = (void *)calloc(nbytes, 1);
#ifdef LOUD
! fprintf(stderr, "new %p %d\n", ret, nbytes);
#endif /* LOUD */
#ifdef DEBUGMEM
***************
*** 75,79 ****
nbytes = 1;
#ifdef LOUD
! fprintf(stderr, "free %x %d\n", (int)fatso, nbytes);
#endif /* LOUD */
#ifdef DEBUGMEM
--- 84,88 ----
nbytes = 1;
#ifdef LOUD
! fprintf(stderr, "free %p %d\n",fatso, nbytes);
#endif /* LOUD */
#ifdef DEBUGMEM
***************
*** 92,99 ****
*/
void *vec = getbytes(nbytes+ (VECTORALIGNMENT/8-1)+sizeof(void *));
! t_int alignment = ((t_int)vec+sizeof(void *))&(VECTORALIGNMENT/8-1); /* get alignment of first possible signal vector byte */
! void *ret = (unsigned char *)vec+sizeof(void *)+(alignment == 0?0:VECTORALIGNMENT/8-alignment); /* calculate aligned pointer */
! *(void **)((unsigned char *)ret-sizeof(void *)) = vec; /* save original memory location */
! return ret;
}
--- 101,123 ----
*/
void *vec = getbytes(nbytes+ (VECTORALIGNMENT/8-1)+sizeof(void *));
!
! #ifdef LOUD
! fprintf(stderr, "getaligned %p %d\n",vec, nbytes);
! #endif /* LOUD */
!
! if (vec != NULL)
! {
! t_int alignment = ((t_int)vec+sizeof(void *))&(VECTORALIGNMENT/8-1); /* get alignment of first possible signal vector byte */
! void *ret = (unsigned char *)vec+sizeof(void *)+(alignment == 0?0:VECTORALIGNMENT/8-alignment); /* calculate aligned pointer */
! *(void **)((unsigned char *)ret-sizeof(void *)) = vec; /* save original memory location */
!
! #ifdef LOUD
! fprintf(stderr, " %p\n",ret);
! #endif /* LOUD */
! return ret;
! }
! else
! return 0;
!
}
***************
*** 102,105 ****
--- 126,133 ----
{
void *ori = *(void **)((unsigned char *)ptr-sizeof(void *)); /* get original memory location */
+
+ #ifdef LOUD
+ fprintf(stderr, "freealigned %p %p %d\n",ptr, ori, nbytes);
+ #endif /* LOUD */
freebytes(ori,nbytes+(VECTORALIGNMENT/8-1)+sizeof(void *));
}
***************
*** 116,119 ****
--- 144,157 ----
}
+ /* TB: copy to aligned vector memory */
+ void *copybytes(void *src, size_t nbytes)
+ {
+ void *ret;
+ ret = getbytes(nbytes);
+ if (nbytes)
+ memcpy(ret, src, nbytes);
+ return (ret);
+ }
+
#ifdef DEBUGMEM
#include <stdio.h>
Index: d_soundfile.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_soundfile.c,v
retrieving revision 1.1.1.2.2.25
retrieving revision 1.1.1.2.2.26
diff -C2 -d -r1.1.1.2.2.25 -r1.1.1.2.2.26
*** d_soundfile.c 9 Oct 2004 00:11:56 -0000 1.1.1.2.2.25
--- d_soundfile.c 20 Oct 2004 21:28:16 -0000 1.1.1.2.2.26
***************
*** 1245,1259 ****
static void soundfiler_t_read(t_soundfiler *x, t_symbol *s,
! int argc, t_atom *argv)
{
int headersize = -1, channels = 0, bytespersamp = 0, bigendian = 0,
! resize = 0, i, j;
long skipframes = 0,
! nframes = 0,
! finalsize = 0, /* new size */
! itemsleft,
maxsize = DEFMAXSIZE,
! itemsread = 0,
! bytelimit = 0x7fffffff;
int fd = -1;
char endianness, *filename;
--- 1245,1259 ----
static void soundfiler_t_read(t_soundfiler *x, t_symbol *s,
! int argc, t_atom *argv)
{
int headersize = -1, channels = 0, bytespersamp = 0, bigendian = 0,
! resize = 0, i, j;
long skipframes = 0,
! nframes = 0,
! finalsize = 0, /* new size */
! itemsleft,
maxsize = DEFMAXSIZE,
! itemsread = 0,
! bytelimit = 0x7fffffff;
int fd = -1;
char endianness, *filename;
***************
*** 1267,1324 ****
while (argc > 0 && argv->a_type == A_SYMBOL &&
! *argv->a_w.w_symbol->s_name == '-')
{
char *flag = argv->a_w.w_symbol->s_name + 1;
! if (!strcmp(flag, "skip"))
! {
! if (argc < 2 || argv[1].a_type != A_FLOAT ||
! ((skipframes = argv[1].a_w.w_float) < 0))
goto usage;
! argc -= 2; argv += 2;
! }
! else if (!strcmp(flag, "nframes"))
! {
! if (argc < 2 || argv[1].a_type != A_FLOAT ||
! ((nframes = argv[1].a_w.w_float) < 0))
goto usage;
! argc -= 2; argv += 2;
! }
! else if (!strcmp(flag, "raw"))
! {
! if (argc < 5 ||
! argv[1].a_type != A_FLOAT ||
! ((headersize = argv[1].a_w.w_float) < 0) ||
! argv[2].a_type != A_FLOAT ||
! ((channels = argv[2].a_w.w_float) < 1) ||
! (channels > MAXSFCHANS) ||
! argv[3].a_type != A_FLOAT ||
! ((bytespersamp = argv[3].a_w.w_float) < 2) ||
! (bytespersamp > 4) ||
! argv[4].a_type != A_SYMBOL ||
! ((endianness = argv[4].a_w.w_symbol->s_name[0]) != 'b'
! && endianness != 'l' && endianness != 'n'))
! goto usage;
! if (endianness == 'b')
! bigendian = 1;
! else if (endianness == 'l')
! bigendian = 0;
! else
! bigendian = garray_ambigendian();
! argc -= 5; argv += 5;
! }
! else if (!strcmp(flag, "resize"))
! {
! resize = 1;
! argc -= 1; argv += 1;
! }
! else if (!strcmp(flag, "maxsize"))
! {
! if (argc < 2 || argv[1].a_type != A_FLOAT ||
! ((maxsize = argv[1].a_w.w_float) < 0))
goto usage;
! resize = 1; /* maxsize implies resize. */
! argc -= 2; argv += 2;
! }
! else goto usage;
}
if (argc < 2 || argc > MAXSFCHANS + 1 || argv[0].a_type != A_SYMBOL)
--- 1267,1324 ----
while (argc > 0 && argv->a_type == A_SYMBOL &&
! *argv->a_w.w_symbol->s_name == '-')
{
char *flag = argv->a_w.w_symbol->s_name + 1;
! if (!strcmp(flag, "skip"))
! {
! if (argc < 2 || argv[1].a_type != A_FLOAT ||
! ((skipframes = argv[1].a_w.w_float) < 0))
goto usage;
! argc -= 2; argv += 2;
! }
! else if (!strcmp(flag, "nframes"))
! {
! if (argc < 2 || argv[1].a_type != A_FLOAT ||
! ((nframes = argv[1].a_w.w_float) < 0))
goto usage;
! argc -= 2; argv += 2;
! }
! else if (!strcmp(flag, "raw"))
! {
! if (argc < 5 ||
! argv[1].a_type != A_FLOAT ||
! ((headersize = argv[1].a_w.w_float) < 0) ||
! argv[2].a_type != A_FLOAT ||
! ((channels = argv[2].a_w.w_float) < 1) ||
! (channels > MAXSFCHANS) ||
! argv[3].a_type != A_FLOAT ||
! ((bytespersamp = argv[3].a_w.w_float) < 2) ||
! (bytespersamp > 4) ||
! argv[4].a_type != A_SYMBOL ||
! ((endianness = argv[4].a_w.w_symbol->s_name[0]) != 'b'
! && endianness != 'l' && endianness != 'n'))
! goto usage;
! if (endianness == 'b')
! bigendian = 1;
! else if (endianness == 'l')
! bigendian = 0;
! else
! bigendian = garray_ambigendian();
! argc -= 5; argv += 5;
! }
! else if (!strcmp(flag, "resize"))
! {
! resize = 1;
! argc -= 1; argv += 1;
! }
! else if (!strcmp(flag, "maxsize"))
! {
! if (argc < 2 || argv[1].a_type != A_FLOAT ||
! ((maxsize = argv[1].a_w.w_float) < 0))
goto usage;
! resize = 1; /* maxsize implies resize. */
! argc -= 2; argv += 2;
! }
! else goto usage;
}
if (argc < 2 || argc > MAXSFCHANS + 1 || argv[0].a_type != A_SYMBOL)
***************
*** 1330,1358 ****
{
if (argv[i].a_type != A_SYMBOL)
! goto usage;
! if (!(garrays[i] =
! (t_garray *)pd_findbyclass(argv[i].a_w.w_symbol, garray_class)))
! {
! pd_error(x, "%s: no such table", argv[i].a_w.w_symbol->s_name);
! goto done;
! }
else if (!garray_getfloatarray(garrays[i], &vecsize[i], &vecs[i]))
error("%s: bad template for tabwrite",
! argv[i].a_w.w_symbol->s_name);
if (finalsize && finalsize != vecsize[i] && !resize)
! {
! post("soundfiler_read: arrays have different lengths; resizing...");
! resize = 1;
! }
! finalsize = vecsize[i];
}
fd = open_soundfile(canvas_getdir(x->x_canvas)->s_name, filename,
! headersize, &bytespersamp, &bigendian, &channels, &bytelimit,
! skipframes);
if (fd < 0)
{
! pd_error(x, "soundfiler_read: %s: %s", filename, (errno == EIO ?
! "unknown or bad header format" : strerror(errno)));
goto done;
}
--- 1330,1358 ----
{
if (argv[i].a_type != A_SYMBOL)
! goto usage;
! if (!(garrays[i] =
! (t_garray *)pd_findbyclass(argv[i].a_w.w_symbol, garray_class)))
! {
! pd_error(x, "%s: no such table", argv[i].a_w.w_symbol->s_name);
! goto done;
! }
else if (!garray_getfloatarray(garrays[i], &vecsize[i], &vecs[i]))
error("%s: bad template for tabwrite",
! argv[i].a_w.w_symbol->s_name);
if (finalsize && finalsize != vecsize[i] && !resize)
! {
! post("soundfiler_read: arrays have different lengths; resizing...");
! resize = 1;
! }
! finalsize = vecsize[i];
}
fd = open_soundfile(canvas_getdir(x->x_canvas)->s_name, filename,
! headersize, &bytespersamp, &bigendian, &channels, &bytelimit,
! skipframes);
if (fd < 0)
{
! pd_error(x, "soundfiler_read: %s: %s", filename, (errno == EIO ?
! "unknown or bad header format" : strerror(errno)));
goto done;
}
***************
*** 1360,1383 ****
if (resize)
{
! /* figure out what to resize to */
long poswas, eofis, framesinfile;
! poswas = lseek(fd, 0, SEEK_CUR);
! eofis = lseek(fd, 0, SEEK_END);
! if (poswas < 0 || eofis < 0)
! {
! pd_error(x, "lseek failed");
! goto done;
! }
! lseek(fd, poswas, SEEK_SET);
! framesinfile = (eofis - poswas) / (channels * bytespersamp);
! if (framesinfile > maxsize)
! {
! pd_error(x, "soundfiler_read: truncated to %d elements", maxsize);
! framesinfile = maxsize;
! }
if (framesinfile > bytelimit / (channels * bytespersamp))
framesinfile = bytelimit / (channels * bytespersamp);
! finalsize = framesinfile;
}
--- 1360,1383 ----
if (resize)
{
! /* figure out what to resize to */
long poswas, eofis, framesinfile;
! poswas = lseek(fd, 0, SEEK_CUR);
! eofis = lseek(fd, 0, SEEK_END);
! if (poswas < 0 || eofis < 0)
! {
! pd_error(x, "lseek failed");
! goto done;
! }
! lseek(fd, poswas, SEEK_SET);
! framesinfile = (eofis - poswas) / (channels * bytespersamp);
! if (framesinfile > maxsize)
! {
! pd_error(x, "soundfiler_read: truncated to %d elements", maxsize);
! framesinfile = maxsize;
! }
if (framesinfile > bytelimit / (channels * bytespersamp))
framesinfile = bytelimit / (channels * bytespersamp);
! finalsize = framesinfile;
}
***************
*** 1392,1516 ****
post("channels: %d", channels);
#endif
!
! /* allocate memory for new array */
! if (resize)
! for (i = 0; i < argc; i++)
! {
! #ifdef SFDEBUG
! post("allocating buffer %d",i);
! #endif
#ifdef _POSIX_MEMLOCK
! munlockall();
#endif
! nvecs[i]=getalignedbytes (finalsize * sizeof(t_float));
! #ifdef _POSIX_MEMLOCK
! mlockall(MCL_FUTURE);
#endif
! /* if we are out of memory, free it again and quit */
! if (nvecs[i]==0)
! {
! pd_error(x, "resize failed");
! for (j=0; j!=i;++j)
! /* if the resizing fails, we'll have to free all arrays again */
! freealignedbytes (nvecs[i],finalsize * sizeof(t_float));
! goto done;
! }
! /* zero samples */
! if(i > channels)
! {
! memset(nvecs[i],0,vecsize[i] * sizeof(t_float));
! }
}
! else
for (i = 0; i < argc; i++)
{
! #ifdef _POSIX_MEMLOCK
! munlockall();
! #endif
! nvecs[i] = getalignedbytes (vecsize[i] * sizeof(t_float));
! #ifdef _POSIX_MEMLOCK
! mlockall(MCL_FUTURE);
! #endif
! /* if we are out of memory, free it again and quit */
! if (nvecs[i]==0)
! {
! pd_error(x, "resize failed");
! for (j=0; j!=i;++j)
! /* if the resizing fails, we'll have to free all arrays again */
! freealignedbytes (nvecs[i],vecsize[i] * sizeof(t_float));
! goto done;
! }
! /* zero samples */
! if(i > channels)
! memset(nvecs[i],0,vecsize[i] * sizeof(t_float));
}
! for (itemsread = 0; itemsread < finalsize; )
! {
! int thisread = finalsize - itemsread;
! thisread = (thisread > bufframes ? bufframes : thisread);
! nitems = fread(sampbuf, channels * bytespersamp, thisread, fp);
! if (nitems <= 0) break;
! soundfile_xferin(channels, argc, nvecs, itemsread,
! (unsigned char *)sampbuf, nitems, bytespersamp, bigendian);
! itemsread += nitems;
! }
!
! /* zero out remaining elements of vectors */
! for (i = 0; i < argc; i++)
! {
! for (j = itemsread; j < finalsize; j++)
! nvecs[i][j] = 0;
! }
!
! /* lock the system and reset the garrays */
! sys_lock();
! for (i = 0; i < argc; i++)
! {
#ifdef GARRAY_THREAD_LOCK
! garray_lock(garrays[i]);
#endif
! garrays[i]->x_array.a_vec = (char *) nvecs[i];
! garrays[i]->x_array.a_n = finalsize;
#ifdef GARRAY_THREAD_LOCK
! garray_unlock(garrays[i]);
#endif
! if (garrays[i]->x_usedindsp) canvas_update_dsp();
! }
! sys_unlock();
! /* do all graphics updates */
! for (i = 0; i < argc; i++)
! {
! t_glist *gl;
! int n = finalsize;
! /* if this is the only array in the graph,
! reset the graph's coordinates */
! gl = garrays[i]->x_glist;
! if (gl->gl_list == &garrays[i]->x_gobj && !garrays[i]->x_gobj.g_next)
{
! vmess(&gl->gl_pd, gensym("bounds"), "ffff",
! 0., gl->gl_y1, (double)(n > 1 ? n-1 : 1), gl->gl_y2);
! /* close any dialogs that might have the wrong info now... */
! gfxstub_deleteforkey(gl);
! }
! else garray_redraw(garrays[i]);
! }
end:
! /* free the old arrays */
! for (i = 0; i < argc; i++)
! freealignedbytes(vecs[i], vecsize[i] * sizeof(t_float));
fclose(fp);
fd = -1;
goto done;
! usage:
pd_error(x, "usage: read [flags] filename tablename...");
post("flags: -skip <n> -nframes <n> -resize -maxsize <n> ...");
post("-raw <headerbytes> <channels> <bytespersamp> <endian (b, l, or n)>.");
! done:
if (fd >= 0)
close (fd);
sys_lock();
outlet_float(x->x_obj.ob_outlet, (float)itemsread);
--- 1392,1511 ----
post("channels: %d", channels);
#endif
!
#ifdef _POSIX_MEMLOCK
! munlockall();
#endif
!
! /* allocate memory for new array */
! if (resize)
! for (i = 0; i < argc; i++)
! {
! #ifdef SFDEBUG
! post("allocating buffer %d",i);
#endif
! nvecs[i]=getalignedbytes (finalsize * sizeof(t_float));
! /* if we are out of memory, free it again and quit */
! if (nvecs[i]==0)
! {
! pd_error(x, "resize failed");
! for (j=0; j!=i;++j)
! /* if the resizing fails, we'll have to free all arrays again */
! freealignedbytes (nvecs[i],finalsize * sizeof(t_float));
! goto done;
! }
! /* zero samples */
! if(i > channels)
! {
! memset(nvecs[i],0,vecsize[i] * sizeof(t_float));
! }
! }
! else
! for (i = 0; i < argc; i++)
! {
! nvecs[i] = getalignedbytes (vecsize[i] * sizeof(t_float));
! /* if we are out of memory, free it again and quit */
! if (nvecs[i]==0)
! {
! pd_error(x, "resize failed");
! for (j=0; j!=i;++j)
! /* if the resizing fails, we'll have to free all arrays again */
! freealignedbytes (nvecs[i],vecsize[i] * sizeof(t_float));
! goto done;
! }
! /* zero samples */
! if(i > channels)
! memset(nvecs[i],0,vecsize[i] * sizeof(t_float));
! }
!
! for (itemsread = 0; itemsread < finalsize; )
! {
! int thisread = finalsize - itemsread;
! thisread = (thisread > bufframes ? bufframes : thisread);
! nitems = fread(sampbuf, channels * bytespersamp, thisread, fp);
! if (nitems <= 0) break;
! soundfile_xferin(channels, argc, nvecs, itemsread,
! (unsigned char *)sampbuf, nitems, bytespersamp, bigendian);
! itemsread += nitems;
}
!
! /* zero out remaining elements of vectors */
for (i = 0; i < argc; i++)
{
! for (j = itemsread; j < finalsize; j++)
! nvecs[i][j] = 0;
}
! /* lock the system and reset the garrays */
! sys_lock();
! for (i = 0; i < argc; i++)
! {
#ifdef GARRAY_THREAD_LOCK
! garray_lock(garrays[i]);
#endif
! garrays[i]->x_array.a_vec = (char *) nvecs[i];
! garrays[i]->x_array.a_n = finalsize;
#ifdef GARRAY_THREAD_LOCK
! garray_unlock(garrays[i]);
#endif
! if (garrays[i]->x_usedindsp) canvas_update_dsp();
! }
! sys_unlock();
! /* do all graphics updates */
! for (i = 0; i < argc; i++)
{
! t_glist *gl;
! int n = finalsize;
! /* if this is the only array in the graph,
! reset the graph's coordinates */
! gl = garrays[i]->x_glist;
! if (gl->gl_list == &garrays[i]->x_gobj && !garrays[i]->x_gobj.g_next)
! {
! vmess(&gl->gl_pd, gensym("bounds"), "ffff",
! 0., gl->gl_y1, (double)(n > 1 ? n-1 : 1), gl->gl_y2);
! /* close any dialogs that might have the wrong info now... */
! gfxstub_deleteforkey(gl);
! }
! else garray_redraw(garrays[i]);
! }
end:
! /* free the old arrays */
! for (i = 0; i < argc; i++)
! freealignedbytes(vecs[i], vecsize[i] * sizeof(t_float));
fclose(fp);
fd = -1;
goto done;
! usage:
pd_error(x, "usage: read [flags] filename tablename...");
post("flags: -skip <n> -nframes <n> -resize -maxsize <n> ...");
post("-raw <headerbytes> <channels> <bytespersamp> <endian (b, l, or n)>.");
! done:
if (fd >= 0)
close (fd);
+ #ifdef _POSIX_MEMLOCK
+ mlockall(MCL_FUTURE);
+ #endif
sys_lock();
outlet_float(x->x_obj.ob_outlet, (float)itemsread);
***************
*** 1658,1662 ****
*/
static void soundfiler_t_resize(t_soundfiler *y, t_symbol *s,
! int argc, t_atom *argv)
{
int was, elemsize; /* array contains was elements of size elemsize */
--- 1653,1657 ----
*/
static void soundfiler_t_resize(t_soundfiler *y, t_symbol *s,
! int argc, t_atom *argv)
{
int was, elemsize; /* array contains was elements of size elemsize */
***************
*** 1671,1680 ****
if (!(x))
{
! pd_error(y, "%s: no such table", argv[0].a_w.w_symbol->s_name);
! goto usage;
}
-
-
vec = (t_float*) x->x_array.a_vec;
was = x->x_array.a_n;
--- 1666,1673 ----
if (!(x))
{
! pd_error(y, "%s: no such table", argv[0].a_w.w_symbol->s_name);
! goto usage;
}
vec = (t_float*) x->x_array.a_vec;
was = x->x_array.a_n;
***************
*** 1682,1729 ****
if ((argv+1)->a_type == A_FLOAT)
{
! n = (int) (argv+1)->a_w.w_float;
}
else
{
! goto usage;
}
if (n == was)
{
! return;
}
if (n < 1) n = 1;
elemsize = template_findbyname(x->x_array.a_templatesym)->t_n * sizeof(t_word);
!
! if (was > n)
! {
! #ifdef _POSIX_MEMLOCK
! munlockall();
! #endif
! nvec = copybytes(x->x_array.a_vec, was * elemsize);
#ifdef _POSIX_MEMLOCK
! mlockall(MCL_FUTURE);
#endif
}
else
{
! #ifdef _POSIX_MEMLOCK
! munlockall();
! #endif
! nvec = getalignedbytes(n * elemsize);
! #ifdef _POSIX_MEMLOCK
! mlockall(MCL_FUTURE);
! #endif
! memcpy (nvec, x->x_array.a_vec, was * elemsize);
! /* LATER should check t_resizebytes result */
! memset(nvec + was*elemsize,
! 0, (n - was) * elemsize);
}
if (!nvec)
{
pd_error(x, "array resize failed: out of memory");
! return;
}
--- 1675,1716 ----
if ((argv+1)->a_type == A_FLOAT)
{
! n = (int) (argv+1)->a_w.w_float;
}
else
{
! goto usage;
}
if (n == was)
{
! return;
}
if (n < 1) n = 1;
elemsize = template_findbyname(x->x_array.a_templatesym)->t_n * sizeof(t_word);
!
#ifdef _POSIX_MEMLOCK
! munlockall();
#endif
+ if (was > n)
+ {
+ nvec = copyalignedbytes(x->x_array.a_vec, was * elemsize);
}
else
{
! nvec = getalignedbytes(n * elemsize);
! memcpy (nvec, x->x_array.a_vec, was * elemsize);
! /* LATER should check t_resizebytes result */
! memset(nvec + was*elemsize,
! 0, (n - was) * elemsize);
}
if (!nvec)
{
pd_error(x, "array resize failed: out of memory");
! #ifdef _POSIX_MEMLOCK
! mlockall(MCL_FUTURE);
! #endif
! return;
}
***************
*** 1743,1754 ****
! /* if this is the only array in the graph,
! reset the graph's coordinates */
gl = x->x_glist;
if (gl->gl_list == &x->x_gobj && !x->x_gobj.g_next)
{
vmess(&gl->gl_pd, gensym("bounds"), "ffff",
! 0., gl->gl_y1, (double)(n > 1 ? n-1 : 1), gl->gl_y2);
! /* close any dialogs that might have the wrong info now... */
gfxstub_deleteforkey(gl);
}
--- 1730,1741 ----
! /* if this is the only array in the graph,
! reset the graph's coordinates */
gl = x->x_glist;
if (gl->gl_list == &x->x_gobj && !x->x_gobj.g_next)
{
vmess(&gl->gl_pd, gensym("bounds"), "ffff",
! 0., gl->gl_y1, (double)(n > 1 ? n-1 : 1), gl->gl_y2);
! /* close any dialogs that might have the wrong info now... */
gfxstub_deleteforkey(gl);
}
***************
*** 1756,1759 ****
--- 1743,1749 ----
freealignedbytes (vec, was * elemsize);
+ #ifdef _POSIX_MEMLOCK
+ mlockall(MCL_FUTURE);
+ #endif
sys_lock();
outlet_float(y->x_obj.ob_outlet, (float)atom_getintarg(1,argc,argv));
***************
*** 1761,1765 ****
return;
! usage:
pd_error(x, "usage: resize tablename size");
}
--- 1751,1755 ----
return;
! usage:
pd_error(x, "usage: resize tablename size");
}
***************
*** 1776,1784 ****
! /* TB: soundfiler_t_const ...
! usage: const table value
! */
static void soundfiler_t_const(t_soundfiler *y, t_symbol *s,
! int argc, t_atom *argv)
{
int size, elemsize; /* array contains was elements of size elemsize */
--- 1766,1774 ----
! /* TB: soundfiler_t_const ...
! usage: const table value
! */
static void soundfiler_t_const(t_soundfiler *y, t_symbol *s,
! int argc, t_atom *argv)
{
int size, elemsize; /* array contains was elements of size elemsize */
***************
*** 1794,1799 ****
if (!(x))
{
! pd_error(y, "%s: no such table", argv[0].a_w.w_symbol->s_name);
! goto usage;
}
--- 1784,1789 ----
if (!(x))
{
! pd_error(y, "%s: no such table", argv[0].a_w.w_symbol->s_name);
! goto usage;
}
***************
*** 1805,1813 ****
if ((argv+1)->a_type == A_FLOAT)
{
! val = (int) (argv+1)->a_w.w_float;
}
else
{
! goto usage;
}
--- 1795,1803 ----
if ((argv+1)->a_type == A_FLOAT)
{
! val = (int) (argv+1)->a_w.w_float;
}
else
{
! goto usage;
}
***************
*** 1820,1831 ****
#endif
nvec = getalignedbytes(size * elemsize);
- #ifdef _POSIX_MEMLOCK
- mlockall(MCL_FUTURE);
- #endif
if (!nvec)
{
pd_error(x, "array resize failed: out of memory");
! return;
}
--- 1810,1821 ----
#endif
nvec = getalignedbytes(size * elemsize);
if (!nvec)
{
pd_error(x, "array resize failed: out of memory");
! #ifdef _POSIX_MEMLOCK
! mlockall(MCL_FUTURE);
! #endif
! return;
}
***************
*** 1833,1840 ****
for (i=0; i!=size; ++i)
{
! nvec[i]=val;
}
-
/* TB: we'll have to be sure that no one is accessing the array */
sys_lock();
--- 1823,1829 ----
for (i=0; i!=size; ++i)
{
! nvec[i]=val;
}
/* TB: we'll have to be sure that no one is accessing the array */
sys_lock();
***************
*** 1850,1861 ****
! /* if this is the only array in the graph,
! reset the graph's coordinates */
gl = x->x_glist;
if (gl->gl_list == &x->x_gobj && !x->x_gobj.g_next)
{
vmess(&gl->gl_pd, gensym("bounds"), "ffff",
! 0., gl->gl_y1, (double)(size > 1 ? size-1 : 1), gl->gl_y2);
! /* close any dialogs that might have the wrong info now... */
gfxstub_deleteforkey(gl);
}
--- 1839,1850 ----
! /* if this is the only array in the graph,
! reset the graph's coordinates */
gl = x->x_glist;
if (gl->gl_list == &x->x_gobj && !x->x_gobj.g_next)
{
vmess(&gl->gl_pd, gensym("bounds"), "ffff",
! 0., gl->gl_y1, (double)(size > 1 ? size-1 : 1), gl->gl_y2);
! /* close any dialogs that might have the wrong info now... */
gfxstub_deleteforkey(gl);
}
***************
*** 1863,1872 ****
freealignedbytes (vec, size * elemsize);
! sys_lock(),
! outlet_float(y->x_obj.ob_outlet, size);
sys_unlock();
return;
! usage:
pd_error(x, "usage: const tablename value");
}
--- 1852,1864 ----
freealignedbytes (vec, size * elemsize);
! #ifdef _POSIX_MEMLOCK
! mlockall(MCL_FUTURE);
! #endif
! sys_lock();
! outlet_float(y->x_obj.ob_outlet, size);
sys_unlock();
return;
! usage:
pd_error(x, "usage: const tablename value");
}