|
Joe Pluta wrote: > ... > And of course, somebody could just as easily mangle a handle as recast a > pointer, couldn't they? My technique was designed to prevent accidental > misuse, not aggressive stupidity. > ... If a non-pointer handle is changed to an invalid one, the worst that can happen is the wrong structure is used by your service (and even that possibility can be reduced by using a handle with some magic number in it). If the handle is a pointer, there's no limit to the badness that can be done by changing the pointer to some other storage or using the pointer as a basing pointer. You're right; both scenarios do involve some level of stupidity or maybe naivete. But even the best programmers are careless sometimes. Easy detection of programmer carelessness and limiting the effects of programmer carelessness are at least as important as small differences in execution speed, imho. I agree that the pointer technique can be safe if used properly. But I don't think it's the best technique to recommend to others.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.