On 2014-08-19 09:10, Frank Kolmann wrote:
also I must admit I dont really know what this code means
p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF);
I know it sets a pointer to the data but what does
(QDFFINFO_t *)((char *) mean ?


p_QDFFBASE + p_QDFFBASE->WDFFINOF
says to add the offset p_QDFFBASE->WDFFINOF to the pointer p_QDFFBASE. In C, when you add an offset, say 5, to a pointer, it doesn't add 5 bytes to the pointer, it adds 5 multiples of the type of the pointer. So if p_QDFFBASE is a pointer to a structure of length 32, adding 5 to the pointer would actually add 5*32 bytes.

(char *) p_QDFFBASE

means to interpret p_QDFFBASE as a pointer to char, no matter what type p_QDFFBASE actually is. This forces the addition of the offset to be in bytes.

(QDFFINFO_t *) casts the resulting pointer to be a pointer to a QDFFINFO_t structure, which allows it to be assigned to p_QDFFINFO.

So the whole thing means to take the p_QDFFBASE pointer, add p_QDFFBASE->WDFFINOF bytes to it, and assign it to p_QDFFINFO.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 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.