[PD-cvs] pd/src x_gui.c,1.3,1.3.4.1

Thomas Grill xovo at users.sourceforge.net
Wed May 11 22:07:06 CEST 2005


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10524/src

Modified Files:
      Tag: devel_0_38
	x_gui.c 
Log Message:
avoid "audio dialog too long" bug by dynamic reservation (only if really necessary)

Index: x_gui.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/x_gui.c,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -C2 -d -r1.3 -r1.3.4.1
*** x_gui.c	6 Sep 2004 20:20:36 -0000	1.3
--- x_gui.c	11 May 2005 20:07:00 -0000	1.3.4.1
***************
*** 45,61 ****
  void gfxstub_new(t_pd *owner, void *key, const char *cmd)
  {
!     char buf[MAXPDSTRING];
      char namebuf[80];
      t_gfxstub *x;
      t_symbol *s;
          /* if any exists with matching key, burn it. */
      for (x = gfxstub_list; x; x = x->x_next)
          if (x->x_key == key)
              gfxstub_deleteforkey(key);
!     if (strlen(cmd) + 50 > MAXPDSTRING)
!     {
!         bug("audio dialog too long");
!         return;
!     }
      x = (t_gfxstub *)pd_new(gfxstub_class);
      sprintf(namebuf, ".gfxstub%lx", (t_int)x);
--- 45,67 ----
  void gfxstub_new(t_pd *owner, void *key, const char *cmd)
  {
!     char stbuf[MAXPDSTRING];
!     char *buf;
      char namebuf[80];
      t_gfxstub *x;
      t_symbol *s;
+     int len = strlen(cmd) + 50;
+ 
          /* if any exists with matching key, burn it. */
      for (x = gfxstub_list; x; x = x->x_next)
          if (x->x_key == key)
              gfxstub_deleteforkey(key);
! 
!     /* TG - if necessary reserve a larger buffer */
!     /* gcc could also dynamically reserve on the stack... keep this for later */
!     if(len > MAXPDSTRING)
!         buf = getbytes(len);
!     else
!         buf = stbuf;
! 
      x = (t_gfxstub *)pd_new(gfxstub_class);
      sprintf(namebuf, ".gfxstub%lx", (t_int)x);
***************
*** 70,73 ****
--- 76,82 ----
      sprintf(buf, cmd, s->s_name);
      sys_gui(buf);
+ 
+     if(buf != stbuf)
+         freebytes(buf,len);
  }
  





More information about the Pd-cvs mailing list