5 ms·
It's not guaranteed by the language that pointers are as big as or bigger than integers. Some architecture somewhere might die horribly on this. comp.lang.c FAQ
by swolchok 17y ago
It's not guaranteed by the language that pointers are as big as or bigger than integers. Some architecture somewhere might die horribly on this. comp.lang.c FAQ on this: http://c-faq.com/ptrs/int2ptr.html http://c-faq.com/ptrs/int2ptr.html
- jwilliams 17y agoYou're right -- the general rule is that ints and ptrs shouldn't be interchanged. However -- In this case, it's likely the number of integers required (controller ids, which I guess might be 1 to 4?) would fit in almost any ptr you can think of. Conversions aren't guaranteed, but if you copy/pack it yourself there shouldn't be a problem -- e.g. do a memcpy of one byte. More likely the author was pointing at the fact that this value was later 'free'd' by the event loop. Which is fairly nasty.
- grsxfcyt 17y agoThe general rule is that you shouldn't go free-ing memory you didn't allocate. I had one colleague who would insist on trying to free FILE* after he had closed the file.