コード例 #1
0
ファイル: port.c プロジェクト: MetaluNetProjects/Zicospital
static int imaction_N1_vpatcher(t_port *x, char *arg)
{
    if (x->x_stackdepth >= x->x_stacksize)
    {
	int rqsz = x->x_stackdepth + 1;
	int sz = rqsz;
	x->x_stack = grow_withdata(&rqsz, &x->x_stackdepth,
				   &x->x_stacksize, x->x_stack,
				   PORT_INISTACK, x->x_stackini,
				   sizeof(*x->x_stack));
	if (rqsz != sz)
	{
	    post("too many embedded patches");
	    return (PORT_FATAL);
	}
    }
    x->x_stack[x->x_stackdepth++] = x->x_nobj;
    x->x_nobj = 0;
    binbuf_addv(x->x_outbb, "ssfffff;",
		gensym("#N"), gensym("canvas"),
		port_getx(x, 2), port_gety(x, 3),
		(float)port_xstretch(port_getint(x, 4) - port_getint(x, 2)),
		(float)port_ystretch(port_getint(x, 5) - port_getint(x, 3)),
		PORT_DEFFONTSIZE);
    return (PORT_NEXT);
}
コード例 #2
0
ファイル: thresh.c プロジェクト: EQ4/Pd-for-LibPd
static void thresh_anything(t_thresh *x, t_symbol *s, int ac, t_atom *av)
{
    int ntotal = x->x_natoms + ac;
    t_atom *buf;
    clock_unset(x->x_clock);
    if (s == &s_) s = 0;
    if (s)
	ntotal++;
    if (ntotal > x->x_size)
    {
	/* LATER if (ntotal > THRESH_MAXSIZE)... (cf prepend) */
	int nrequested = ntotal;
	x->x_message = grow_withdata(&nrequested, &x->x_natoms,
				     &x->x_size, x->x_message,
				     THRESH_INISIZE, x->x_messini,
				     sizeof(*x->x_message));
	if (nrequested != ntotal)
	{
	    x->x_natoms = 0;
	    if (ac >= x->x_size)
		ac = (s ? x->x_size - 1 : x->x_size);
	}
    }
    buf = x->x_message + x->x_natoms;
    if (s)
    {
	SETSYMBOL(buf, s);
	buf++;
	x->x_natoms++;
    }
    if (ac)
    {
	memcpy(buf, av, ac * sizeof(*buf));
	x->x_natoms += ac;
    }
    clock_delay(x->x_clock, x->x_thresh);
}
コード例 #3
0
ファイル: prepend.c プロジェクト: Angeldude/pd
static void prepend_anything(t_prepend *x, t_symbol *s, int ac, t_atom *av)
{
    int reentered = x->x_entered;
    int prealloc = !reentered;
    int ntotal = x->x_natoms + ac;
    t_atom *buf;
    x->x_entered = 1;
    if (s == &s_) s = 0;
    if (s)
	ntotal++;
    if (prealloc && ntotal > x->x_size)
    {
	if (ntotal > PREPEND_MAXSIZE)
	    prealloc = 0;
	else
	{
	    int nrequested = ntotal;
	    x->x_message = grow_withdata(&nrequested, &x->x_natoms,
					 &x->x_size, x->x_message,
					 PREPEND_INISIZE, x->x_messini,
					 sizeof(*x->x_message));
	    prealloc = (nrequested == ntotal);
	}
    }
    if (prealloc)
    {
	buf = x->x_message + x->x_natoms;
	if (s)
	{
	    SETSYMBOL(buf, s);
	    buf++;
	}
	if (ac)
	    memcpy(buf, av, ac * sizeof(*buf));
	prepend_dooutput(x, x->x_selector, ntotal, x->x_message);
    }
    else
    {
	/* LATER consider using the stack if ntotal <= MAXSTACK */
	if (buf = getbytes(ntotal * sizeof(*buf)))
	{
	    t_atom *bp = buf + x->x_natoms;
	    if (x->x_natoms)
		memcpy(buf, x->x_message, x->x_natoms * sizeof(*buf));
	    if (s)
	    {
		SETSYMBOL(bp, s);
		bp++;
	    }
	    if (ac)
		memcpy(bp, av, ac * sizeof(*bp));
	    prepend_dooutput(x, x->x_selector, ntotal, buf);
	    freebytes(buf, ntotal * sizeof(*buf));
	}
    }
    if (!reentered)
    {
	x->x_entered = 0;
	if (x->x_auxbuf)
	{
	    if (x->x_auxsize <= x->x_size)
	    {
		x->x_natoms = x->x_auxsize / 2;
		memcpy(x->x_message, x->x_auxbuf,
		       x->x_natoms * sizeof(*x->x_message));
		freebytes(x->x_auxbuf, x->x_auxsize * sizeof(*x->x_auxbuf));
	    }
	    else
	    {
		if (x->x_message != x->x_messini)
		    freebytes(x->x_message, x->x_size * sizeof(*x->x_message));
		x->x_size = x->x_auxsize;
		x->x_message = x->x_auxbuf;
		x->x_natoms = x->x_auxsize / 2;
	    }
	    x->x_auxbuf = 0;
	}
    }
}
コード例 #4
0
ファイル: Scope.c プロジェクト: amurtet/pd-cyclone
static void scope_bufsize(t_scope *x, t_symbol *s, int ac, t_atom *av)
{
    t_float bufsize = (s ? x->x_bufsize : SCOPE_DEFBUFSIZE);
    int result = loud_floatarg(*(t_pd *)x, (s ? 0 : 4), ac, av, &bufsize,
			       SCOPE_MINBUFSIZE, SCOPE_WARNBUFSIZE,
			       /* LATER rethink warning rules */
			       (s ? LOUD_CLIP : LOUD_CLIP | LOUD_WARN), 0,
			       "display elements");
    if (result == LOUD_ARGOVER)
    {
	bufsize = (s ? x->x_bufsize : SCOPE_DEFBUFSIZE);
	result = loud_floatarg(*(t_pd *)x, (s ? 0 : 4), ac, av, &bufsize,
			       0, SCOPE_MAXBUFSIZE, 0, LOUD_CLIP | LOUD_WARN,
			       "display elements");
	if (!s && result == LOUD_ARGOK)
	    fittermax_warning(*(t_pd *)x,
			      "more than %g display elements requested",
			      SCOPE_WARNBUFSIZE);
    }
    if (!s)
    {
	x->x_allocsize = SCOPE_DEFBUFSIZE;
	x->x_bufsize = 0;
	x->x_xbuffer = x->x_xbufini;
	x->x_ybuffer = x->x_ybufini;
    }
    if (!s || result == LOUD_ARGOK)
    {
	int newsize = (int)bufsize;
	if (newsize > x->x_allocsize)
	{
	    int nrequested = newsize;
	    int allocsize = x->x_allocsize;
	    int oldsize = x->x_bufsize;
	    x->x_xbuffer = grow_withdata(&nrequested, &oldsize,
					 &allocsize, x->x_xbuffer,
					 SCOPE_DEFBUFSIZE, x->x_xbufini,
					 sizeof(*x->x_xbuffer));
	    if (nrequested == newsize)
	    {
		allocsize = x->x_allocsize;
		oldsize = x->x_bufsize;
		x->x_ybuffer = grow_withdata(&nrequested, &oldsize,
					     &allocsize, x->x_ybuffer,
					     SCOPE_DEFBUFSIZE, x->x_ybufini,
					     sizeof(*x->x_ybuffer));
	    }
	    if (nrequested == newsize)
	    {
		x->x_allocsize = allocsize;
		x->x_bufsize = newsize;
	    }
	    else
	    {
		if (x->x_xbuffer != x->x_xbufini)
		    freebytes(x->x_xbuffer,
			      x->x_allocsize * sizeof(*x->x_xbuffer));
		if (x->x_ybuffer != x->x_ybufini)
		    freebytes(x->x_ybuffer,
			      x->x_allocsize * sizeof(*x->x_ybuffer));
		x->x_allocsize = SCOPE_DEFBUFSIZE;
		x->x_bufsize = SCOPE_DEFBUFSIZE;
		x->x_xbuffer = x->x_xbufini;
		x->x_ybuffer = x->x_ybufini;
	    }
	}
	else x->x_bufsize = newsize;
	scope_clear(x, 0);
    }
}