Update of /cvsroot/pure-data/externals/zexy/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3206
Modified Files: index.c Log Message: when we add an item at a certain index that exceeds the number of elements, we resize the array to be able to hold the new index. use of "verbose()"
Index: index.c =================================================================== RCS file: /cvsroot/pure-data/externals/zexy/src/index.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** index.c 30 Jun 2005 18:32:56 -0000 1.8 --- index.c 27 Oct 2005 11:58:10 -0000 1.9 *************** *** 127,135 **** int newentry=(int)f; int ok = 0; ! if (! (find_item(s, x->names, x->maxentries)+1) ) { ! if (x->auto_resize && x->entries==x->maxentries){ /* do some resizing */ ! int maxentries=x->maxentries*2; int i; t_symbol**buf=(t_symbol **)getbytes(sizeof(t_symbol *) * maxentries); --- 127,135 ---- int newentry=(int)f; int ok = 0; ! if (! (find_item(s, x->names, x->maxentries)+1) ) { ! if (x->auto_resize && (x->entries==x->maxentries || newentry>=x->maxentries)){ /* do some resizing */ ! int maxentries=(newentry>x->maxentries)?newentry:(x->maxentries*2); int i; t_symbol**buf=(t_symbol **)getbytes(sizeof(t_symbol *) * maxentries); *************** *** 149,163 **** newentry--; if(x->names[newentry]){ /* it is already taken! */ ! error("index :: couldn't add element '%s' at position %d (already taken)", s->s_name, newentry+1); outlet_float(x->x_obj.ob_outlet, -1.f); return; } ! } else newentry=find_free(x->names, x->maxentries); ! if (newentry + 1) { x->entries++; x->names[newentry]=s; - outlet_float(x->x_obj.ob_outlet, (t_float)newentry+1); return; --- 149,162 ---- newentry--; if(x->names[newentry]){ /* it is already taken! */ ! verbose(1, "index :: couldn't add element '%s' at position %d (already taken)", s->s_name, newentry+1); outlet_float(x->x_obj.ob_outlet, -1.f); return; } ! } else { newentry=find_free(x->names, x->maxentries); ! } if (newentry + 1) { x->entries++; x->names[newentry]=s; outlet_float(x->x_obj.ob_outlet, (t_float)newentry+1); return; *************** *** 165,170 **** } else error("index :: couldn't find any place for new entry"); } else error("index :: max number of elements (%d) reached !", x->maxentries); ! } else post("index :: element '%s' already exists", s->s_name); ! /* couldn't add the symbol to our index table */ outlet_float(x->x_obj.ob_outlet, -1.f); --- 164,168 ---- } else error("index :: couldn't find any place for new entry"); } else error("index :: max number of elements (%d) reached !", x->maxentries); ! } else verbose(1, "index :: element '%s' already exists", s->s_name); /* couldn't add the symbol to our index table */ outlet_float(x->x_obj.ob_outlet, -1.f); *************** *** 193,197 **** outlet_float(x->x_obj.ob_outlet, 0.0); } else { ! post("index :: couldn't find element"); outlet_float(x->x_obj.ob_outlet, -1.0); } --- 191,195 ---- outlet_float(x->x_obj.ob_outlet, 0.0); } else { ! verbose(1, "index :: couldn't find element"); outlet_float(x->x_obj.ob_outlet, -1.0); } *************** *** 223,227 **** t_atom ap[2]; int i=0; - for(i=0; i<x->maxentries; i++){ if(x->names[i]){ --- 221,224 ----