c - Get struct's size passed as void to function -


i'm changing codes in database library. way works send void pointer, size of call query , using query calculate size of structure. problem receive struct params function fails before/in middle of first fetch. after need clear structure, dont have size. know best way send size of structure param, have thousands , thousands programs compiled, library 1996, need find way calculate structure size if type void.

one idea had calculate position of next element not in structure

0x000010              0x000042 [int|char[30]|int|int][int] 

so size 32, because 0x00042-0x000010 32.

is there way know when got out of structure.

the prototype of function is

int getdata(char* fields, void* mystruct) 

i need find out structure size.

sorry if missed information, code huge , unfortunately cannot post here.

no, in general there's no way, given void *, figure out you're after. thing can compare against null, of course doesn't here.

note there's nothing in void * says points @ struct, pointing middle of array.

if have global means of recording pointers before they're passed getdata(), might able implement look-up function compares pointer value against recorded, that's using pointer value key.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -