Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2360
Modified Files: Tag: desiredata builtins.c Log Message: remove useless t_listelem.
Index: builtins.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/builtins.c,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -C2 -d -r1.1.2.11 -r1.1.2.12 *** builtins.c 9 Jan 2007 15:07:39 -0000 1.1.2.11 --- builtins.c 9 Jan 2007 18:33:54 -0000 1.1.2.12 *************** *** 668,699 ****
/* -------------- utility functions: storage, copying -------------- */ - /* List element for storage. Keep an atom and, in case it's a pointer, - an associated 'gpointer' to protect against stale pointers. */ - struct t_listelem { - t_atom a; - t_gpointer l_p; - };
typedef struct t_alist : t_pd { int n; /* number of items */ ! t_listelem *l_vec; /* pointer to items */ };
- #if 0 /* probably won't use this version... */ - #ifdef HAVE_ALLOCA - #define LIST_ALLOCA(x, n) ( \ - (x).n = (n), \ - (x).l_vec = (t_listelem *)((n) < LIST_NGETBYTE ? \ - alloca((n) * sizeof(t_listelem)) : getbytes((n) * sizeof(t_listelem)))) \ - #define LIST_FREEA(x) (((x).n < LIST_NGETBYTE || (free((x).l_vec), 0))) - - #else - #define LIST_ALLOCA(x, n) ( \ - (x).n = (n), \ - (x).l_vec = (t_listelem *)getbytes((n) * sizeof(t_listelem))) - #define LIST_FREEA(x) (free((x).l_vec)) - #endif - #endif - #if HAVE_ALLOCA #define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)((n) < LIST_NGETBYTE ? \ --- 668,678 ----
/* -------------- utility functions: storage, copying -------------- */
+ /* damn like binbuf */ typedef struct t_alist : t_pd { int n; /* number of items */ ! t_atom *v; /* pointer to items */ };
#if HAVE_ALLOCA #define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)((n) < LIST_NGETBYTE ? \ *************** *** 715,756 **** x->_class = alist_class; x->n = 0; ! x->l_vec = 0; } static void alist_clear(t_alist *x) { for (int i = 0; i < x->n; i++) ! if (x->l_vec[i].a.a_type == A_POINTER) gpointer_unset(x->l_vec[i].a.a_w.w_gpointer); ! if (x->l_vec) free(x->l_vec); } static void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv) { alist_clear(x); ! if (!(x->l_vec = (t_listelem *)getbytes(argc * sizeof(*x->l_vec)))) { ! x->n = 0; ! error("list_alloc: out of memory"); ! return; ! } x->n = argc; ! for (int i = 0; i < argc; i++) { ! x->l_vec[i].a = argv[i]; ! if (x->l_vec[i].a.a_type == A_POINTER) ! gpointer_copy(x->l_vec[i].a.a_w.w_gpointer, &x->l_vec[i].l_p); ! } } static void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv) { alist_clear(x); ! if (!(x->l_vec = (t_listelem *)getbytes((argc+1) * sizeof(*x->l_vec)))) { ! x->n = 0; ! error("list_alloc: out of memory"); ! return; ! } x->n = argc+1; ! SETSYMBOL(&x->l_vec[0].a, s); ! for (int i = 0; i < argc; i++) { ! x->l_vec[i+1].a = argv[i]; ! if (x->l_vec[i+1].a.a_type == A_POINTER) ! gpointer_copy(x->l_vec[i+1].a.a_w.w_gpointer, &x->l_vec[i+1].l_p); ! } } static void alist_toatoms(t_alist *x, t_atom *to) { ! for (int i = 0; i < x->n; i++) to[i] = x->l_vec[i].a; } static void alist_setup() { --- 694,721 ---- x->_class = alist_class; x->n = 0; ! x->v = 0; } static void alist_clear(t_alist *x) { for (int i = 0; i < x->n; i++) ! if (x->v[i].a_type == A_POINTER) gpointer_unset(x->v[i].a_w.w_gpointer); ! if (x->v) free(x->v); } static void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv) { alist_clear(x); ! x->v = (t_atom *)getbytes(argc * sizeof(*x->v)); ! if (!x->v) {x->n = 0; error("list_alloc: out of memory"); return;} x->n = argc; ! for (int i = 0; i < argc; i++) x->v[i] = argv[i]; } static void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv) { alist_clear(x); ! x->v = (t_atom *)getbytes((argc+1) * sizeof(*x->v)); ! if (!x->v) {x->n = 0; error("list_alloc: out of memory"); return;} x->n = argc+1; ! SETSYMBOL(&x->v[0], s); ! for (int i = 0; i < argc; i++) x->v[i+1] = argv[i]; } static void alist_toatoms(t_alist *x, t_atom *to) { ! for (int i = 0; i < x->n; i++) to[i] = x->v[i]; } static void alist_setup() {