So I am working away on the Mac OS X version of [hid] and I made these changes, and while I was doing it, I had another idea. Basically, when [hid] is running, it generates a ton of symbol lookups if its doing multiple gensym()s for every output.
Would it be worthwhile to create an array of symbol pointers when [hid] is loaded? Then when outputting it would use the event numbers to get the symbol pointers.
.hc
On Apr 7, 2006, at 11: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:
- (hid_linux): get the name (*char)
- (hid_linux): copy it to to event_name (char[7])
- (hid_linux): pass &event_name to hid::hid_output_event()
- (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):
- (hid_linux); get the name (char*) and gensym() it
- (hid_linux): pass the symbol to hid::hid_output_event()
- (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:
- (hid_linux); get the name (char*) and gensym() it
- (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@iem.at http://lists.puredata.info/listinfo/pd-dev
________________________________________________________________________ ____
I spent 33 years and four months in active military service and during that period I spent most of my time as a high class muscle man for Big Business, for Wall Street and the bankers. - General Smedley Butler