[PD-dev] hid crashing (again...) +fixes

Hans-Christoph Steiner hans at eds.org
Fri Apr 7 17:00:10 CEST 2006


What can I say, I am a bad C programmer ;).  This is great, I am glad  
you looked into it.  The implementation of [hid] could definitely use  
some work.

I'll check out your changes when I get a chance.  I was planning on  
using longer names anyhow.  Part of the structure comes from the  
Linux input system, since I based [hid] on it.

As for the build changes, make sure you don't break anything with Pd- 
extended.  The last thing I need is more build problems to deal with.

.hc

On Apr 7, 2006, at 5:18 AM, IOhannes m zmoelnig wrote:

> hi
>
> using hid i had problems with my joystick, crashing immediately as  
> soon
> as i used the throttle.
>
> the reason turned out to be a fixed-sized character array which was
> limited to 7(!) characters and strcpy'ing names without any checks.
> unfortunately my "abs_throttle" is a bit longer than 7 characters.
>
> now i am wondering why all the event-name handling is done via
> character-arrays and not with pd symbols?
>
> pollution of the symbol-table can not be the problem, since what is
> going on is something like that:
> 1. (hid_linux): get the name (*char)
> 2. (hid_linux): copy it to to event_name (char[7])
> 3. (hid_linux): pass &event_name to hid::hid_output_event()
> 4. (hid): gensym(event_name) and output it
>
> i don't see any good reason to not generate the t_symbol's much  
> earlier
> in the process, in order to allow names of any length (and let pd  
> handle
> the allocation):
> 1. (hid_linux); get the name (char*) and gensym() it
> 2. (hid_linux): pass the symbol to hid::hid_output_event()
> 3. (hid): output the symbol
>
> i have committed several changes to the CVS, but since i didn't  
> want to
> break the API where i cannot test (osX), i have only changed
> hid_linux.c; this complicates the code a bit to:
> 1. (hid_linux); get the name (char*) and gensym() it
> 2. (hid_linux): pass the char* in the symbol (s->s_name) to
> hid::hid_output_event()
> 3. (hid): gensym() it again and output
> this involves 2 symhashtable lookups instead of just one.
>
> so the question is: is this by (bad) design?
>
> any objections to change (in hid.[ch])
>  void hid_output_event(t_hid *x, char *type, char *code, t_float  
> value);
> to
>  void hid_output_event(t_hid *x, t_symbol*type, t_symbol*code, t_float
> value);
> ??
>
>
> mfga.sdr.
> IOhannes
>
> PS: i also did some other (small) changes, in order to make it  
> possible
> to compile this object without having 80MB of code checked out
>
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev


________________________________________________________________________ 
____

If you are not part of the solution, you are part of the problem.
                                                               -  
Eldridge Cleaver





More information about the Pd-dev mailing list