t_symbol to t_atom help


    Oct 15 2006 | 1:17 pm
    In my myobj_anything function, i want to forward all the arguments as a new ac, av, with the t_symbol *s included as the first av. I try this, where 'templist' is still a member of my object struct (t_atom templist[MAXSIZE]) :
    SETSYM(x->templist+0, s); short i; for (i=0; itemplist[i+1] = *av; remote(x, x->target, ac, av); // this is a call to the remote function by I. Zannos : void remote(t_fwd *x,t_symbol *s, int ac, t_atom *av) ;
    ... then *BOOM*
    Any help ?
    cheers
    f.e
    -- f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|

    • Oct 15 2006 | 1:32 pm
      is x->target a symbol?
      is ac == MAXSIZE?
      Why are you going to the trouble to copy av into x->templist if you're just passing av into remote()?
      There is nothing wrong with the code you have pasted here, but you haven't given enough information (as usual!) for us to understand the context, so, well, who knows? In general, 5 lines of code will never be enough for anyone to analyze your problem, unless your problem is extremely fundamental. Please try to get in the habit of including full (relevant) source for the problems you are experiencing.
      jb
      Am 15.10.2006 um 15:17 schrieb f.e:
      > SETSYM(x->templist+0, s); > short i; > for (i=0; itemplist[i+1] = *av; > remote(x, x->target, ac, av); // this is a call to the remote > function by I. Zannos : void remote(t_fwd *x,t_symbol *s, int ac, > t_atom *av) ; > ... then *BOOM*
    • Oct 15 2006 | 1:47 pm
      Sorry Jeremy. I always thought writing too much will bother and i wasn't aware i was breaking your b**** by posting too few lines of code. I'll keep it in mind from now on.
      my object struct :
      #define MAXSIZE 256
      typedef struct _fwd { t_object m_ob; t_symbol *target; // dynamic name of the target(s) t_symbol *prefix; // symbol defined as a prefix t_symbol *argument; int mode; // 0 = normal, 1 = prefix, 2=defined receiver t_atom templist[MAXSIZE]; void *t_anyout; } t_fwd;
      void fwd_anything(t_fwd *x, t_symbol *s, short ac, t_atom *av) { switch(x->mode) { case 0: blabla case 1: blabla case 2: { SETSYM(x->templist+0, s); // ! this is the problem... ! short i; for (i=0; itemplist[i+1] = *av; //remote(x, x->target, ac+1, x->templist); // for debug only outlet_anything(x->t_anyout, 0L, ac+1, x->templist); //post("ac = %d", ac+1); //post("av+0 = %s", x->templist->a_w.w_sym->s_name); // end of debug only break; } } }
      t_anyout is was you think it is.
      Forget about the remote function, it is not the problem. Same crashes with outlet_anything.
      cheers
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      Jeremy Bernstein wrote: > is x->target a symbol? > > is ac == MAXSIZE? > > Why are you going to the trouble to copy av into x->templist if you're > just passing av into remote()? > > There is nothing wrong with the code you have pasted here, but you > haven't given enough information (as usual!) for us to understand the > context, so, well, who knows? In general, 5 lines of code will never > be enough for anyone to analyze your problem, unless your problem is > extremely fundamental. Please try to get in the habit of including > full (relevant) source for the problems you are experiencing. > > jb > > Am 15.10.2006 um 15:17 schrieb f.e: > >> SETSYM(x->templist+0, s); >> short i; >> for (i=0; itemplist[i+1] = *av; >> remote(x, x->target, ac, av); // this is a call to the remote >> function by I. Zannos : void remote(t_fwd *x,t_symbol *s, int ac, >> t_atom *av) ; >> ... then *BOOM* > >
    • Oct 15 2006 | 1:55 pm
      > > > Why are you going to the trouble to copy av into x->templist if you're > just passing av into remote()? I wish the t_symbol *s of my anything function to be the first element of av...
      f.e
    • Oct 15 2006 | 2:07 pm
      Am 15.10.2006 um 15:47 schrieb f.e:
      > outlet_anything(x->t_anyout, 0L, ac+1, x->templist);
      not that i'm really remembering all the details, but are you sure you can just pass 0L instead of gensym("list")? Moreover there ought to be a outlet_list function for that. Funny that programming using flext made me forget all the native stuff.
      greetings, Thomas
      -- Thomas Grill http://grrrr.org
    • Oct 15 2006 | 2:10 pm
      What happens if you change this to atom_setsym(x->templist, s)? I find it very hard to believe that this is really your problem, though. What kind of input are you sending to the function?
      jb
      Am 15.10.2006 um 15:47 schrieb f.e:
      > SETSYM(x->templist+0, s); // ! this is the problem... !
    • Oct 15 2006 | 2:18 pm
      Am 15.10.2006 um 15:17 schrieb f.e: > SETSYM(x->templist+0, s); > short i; > for (i=0; itemplist[i+1] = *av; > remote(x, x->target, ac, av); // this is a call to the remote > function by I. Zannos : void remote(t_fwd *x,t_symbol *s, int ac, > t_atom *av) ;
      OK, there _was_ a problem with this version -- note that you've increasingly incremented av? So, when you called remote(), you were passing in (original av + ac) instead of (original av) -- an invalid pointer. When it gets dereferenced - boom.
      Thomas' comment re: outlet_list is also correct, and may be why you are crashing out with outlet_anything.
      Try either outlet_list(x->t_anyout, 0L, ac+1, x->templist);
      or
      outlet_anything(x->t_anyout, x->templist[0].a_w.w_sym, ac, &x- >templist[1]);
      jb
    • Oct 15 2006 | 3:52 pm
      Yes, i've already noticed and and changed outlet_anything(x->t_anyout, 0L, ac+1, x->templist); (stupid mistake)
      But changing SETSYM(x->templist+0, s); to atom_setsym(x->templist, s) doesn't change... Still crashes.
      I just send simple list of symbols, like 'hello how are you'. When i send a list, my function works well because it doesn't care about the first hidden symbol which is "list", if i'm not wrong. So, passing '167 how are you' is ok. But 'hello how are you' to my anything function doesn't. I just want the 'hello' to be included in the av...
      I'm sure you all made this a dozen time before : just adding the first symbol of an anyhting function to the av list... ?!
      Damn stuck...
      cheers
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      Jeremy Bernstein wrote: > What happens if you change this to atom_setsym(x->templist, s)? I find > it very hard to believe that this is really your problem, though. What > kind of input are you sending to the function? > > jb > > Am 15.10.2006 um 15:47 schrieb f.e: > >> SETSYM(x->templist+0, s); // ! this is the problem... ! > >
    • Oct 16 2006 | 9:31 am
      Hey, Jeremy, don't leave me down !
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      Jeremy Bernstein wrote: > Am 15.10.2006 um 15:17 schrieb f.e: >> SETSYM(x->templist+0, s); >> short i; >> for (i=0; itemplist[i+1] = *av; >> remote(x, x->target, ac, av); // this is a call to the remote >> function by I. Zannos : void remote(t_fwd *x,t_symbol *s, int ac, >> t_atom *av) ; > > > OK, there _was_ a problem with this version -- note that you've > increasingly incremented av? So, when you called remote(), you were > passing in (original av + ac) instead of (original av) -- an invalid > pointer. When it gets dereferenced - boom. > > Thomas' comment re: outlet_list is also correct, and may be why you > are crashing out with outlet_anything. > > Try either > outlet_list(x->t_anyout, 0L, ac+1, x->templist); > > or > > outlet_anything(x->t_anyout, x->templist[0].a_w.w_sym, ac, > &x->templist[1]); > > jb > > >
    • Oct 16 2006 | 2:14 pm