[PD-cvs] pd/src kernel.c,1.1.2.39,1.1.2.40

Mathieu Bouchard matju at users.sourceforge.net
Tue Jan 16 00:12:04 CET 2007


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

Modified Files:
      Tag: desiredata
	kernel.c 
Log Message:
added pd_free_zombie


Index: kernel.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v
retrieving revision 1.1.2.39
retrieving revision 1.1.2.40
diff -C2 -d -r1.1.2.39 -r1.1.2.40
*** kernel.c	10 Jan 2007 03:15:29 -0000	1.1.2.39
--- kernel.c	15 Jan 2007 23:12:01 -0000	1.1.2.40
***************
*** 125,129 ****
  	self->i = 0;
  	self->tab = (t_hashentry **)malloc(capa*sizeof(void*));
- //	fprintf(stderr,"hash_set %d\n",capa);
  	for (long i=0; i<capa; i++) self->tab[i]=0;
  	return self;
--- 125,128 ----
***************
*** 299,303 ****
      t_pd *x = (t_pd *)getbytes(c->size);
      x->_class = c;
!     hash_set(object_table,x,(void*)0);
      if (c->gobj) ((t_gobj *)x)->g_adix = appendix_new((t_gobj *)x);
      if (c->patchable) {
--- 298,302 ----
      t_pd *x = (t_pd *)getbytes(c->size);
      x->_class = c;
!     hash_set(object_table,x,(void*)1);
      if (c->gobj) ((t_gobj *)x)->g_adix = appendix_new((t_gobj *)x);
      if (c->patchable) {
***************
*** 308,316 ****
  }
  
  void pd_free(t_pd *x) {
      t_class *c = x->_class;
      if (c->freemethod) ((t_gotfn)(c->freemethod))(x);
-     if (c->gobj) appendix_free((t_gobj *)x);
-     hash_delete(object_table,x);
      if (c->patchable) {
  	t_object *y = (t_object *)x;
--- 307,319 ----
  }
  
+ extern "C" void pd_free_zombie(t_pd *x) {
+ 	t_class *c = x->_class;
+ 	if (c->gobj) appendix_free((t_gobj *)x);
+ 	if (c->size) free(x);
+ }
+ 
  void pd_free(t_pd *x) {
      t_class *c = x->_class;
      if (c->freemethod) ((t_gotfn)(c->freemethod))(x);
      if (c->patchable) {
  	t_object *y = (t_object *)x;
***************
*** 319,323 ****
  	if (y->ob_binbuf)    binbuf_free(y->ob_binbuf);
      }
!     if (c->size) free(x);
  }
  
--- 322,327 ----
  	if (y->ob_binbuf)    binbuf_free(y->ob_binbuf);
      }
!     /* schedule for deletion if need to keep the allocation around */
!     if (c->gobj && 0 /*is in the client*/) hash_set(object_table,x,0); else pd_free_zombie(x);
  }
  
***************
*** 1343,1349 ****
      /* this routine is called when a new "object" is requested whose class Pd
      doesn't know.  Pd tries to load it as an extern, then as an abstraction. */
! void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv)
! {
!     t_pd *current;
      int fd;
      char dirbuf[MAXPDSTRING], *nameptr;
--- 1347,1351 ----
      /* this routine is called when a new "object" is requested whose class Pd
      doesn't know.  Pd tries to load it as an extern, then as an abstraction. */
! void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv) {
      int fd;
      char dirbuf[MAXPDSTRING], *nameptr;
***************
*** 1351,1356 ****
      newest = 0;
      class_loadsym = s;
!     if (sys_load_lib(canvas_getcurrent(), s->name))
!     {
          tryingalready = 1;
          typedmess((t_pd *)dummy, s, argc, argv);
--- 1353,1357 ----
      newest = 0;
      class_loadsym = s;
!     if (sys_load_lib(canvas_getcurrent(), s->name)) {
          tryingalready = 1;
          typedmess((t_pd *)dummy, s, argc, argv);
***************
*** 1359,1363 ****
      }
      class_loadsym = 0;
!     current = s__X.thing;
      if ((fd = canvas_open(canvas_getcurrent(), s->name, ".pd",  dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 ||
          (fd = canvas_open(canvas_getcurrent(), s->name, ".pat", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) {
--- 1360,1364 ----
      }
      class_loadsym = 0;
!     t_pd *current = s__X.thing;
      if ((fd = canvas_open(canvas_getcurrent(), s->name, ".pd",  dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 ||
          (fd = canvas_open(canvas_getcurrent(), s->name, ".pat", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) {
***************
*** 1366,1371 ****
              canvas_setargs(argc, argv); /* bug fix by Krzysztof Czaja */
              binbuf_evalfile(gensym(nameptr), gensym(dirbuf));
!             if (s__X.thing != current)
!                 canvas_popabstraction((t_canvas *)(s__X.thing));
              canvas_setargs(0, 0);
          }
--- 1367,1371 ----
              canvas_setargs(argc, argv); /* bug fix by Krzysztof Czaja */
              binbuf_evalfile(gensym(nameptr), gensym(dirbuf));
!             if (s__X.thing != current) canvas_popabstraction((t_canvas *)s__X.thing);
              canvas_setargs(0, 0);
          }
***************
*** 1805,1812 ****
  }
  
! /* convert a binbuf to text with null termination and malloc. */
  char *binbuf_gettext2(t_binbuf *x) {
!   char *buf = (char *)malloc(MAXPDSTRING);
!   int n;
    binbuf_gettext(x,&buf,&n);
    buf[n] = 0;
--- 1805,1811 ----
  }
  
! /* convert a binbuf to text with null termination, as return value */
  char *binbuf_gettext2(t_binbuf *x) {
!   char *buf; int n;
    binbuf_gettext(x,&buf,&n);
    buf[n] = 0;
***************
*** 1897,1901 ****
      int newsize = x->n + argc, i;
      t_atom *ap;
!     ap = (t_atom *)realloc(x->v,newsize*sizeof(*x->v));
      if (!ap) {
          error("binbuf_addmessage: out of space");
--- 1896,1900 ----
      int newsize = x->n + argc, i;
      t_atom *ap;
!     ap = (t_atom *)realloc(x->v,(newsize+1)*sizeof(*x->v));
      if (!ap) {
          error("binbuf_addmessage: out of space");
***************
*** 2069,2073 ****
  		if (!sscanf(s->name,".x%lx",(long*)&target)) target=0;
  		if (target) {
! 			if (!hash_exists(object_table,target)) {
  				error("%s target is not a currently valid pointer",s->name);
  				return;
--- 2068,2072 ----
  		if (!sscanf(s->name,".x%lx",(long*)&target)) target=0;
  		if (target) {
! 			if (!hash_exists(object_table,target) || !hash_get(object_table,target)) {
  				error("%s target is not a currently valid pointer",s->name);
  				return;





More information about the Pd-cvs mailing list