Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
since we are at it, I always thought a dry run of the same function can be used to return the required size but I have never seen this anywhere and don't know if I want to be the first :) For example getData(NULL, bfrSize) where the pointer is NULL, the function knows just to return the required size in bfrSize. Would that be too bad?
What I am not sure about is the client is passing the buffer pointer and size, it doesn't seem to recognize how much buffer size the function actually needs which is defined by #define in header file. I guess first thing my function has to to do is check if the buffer size is at least as big as MAX_ITEMS_SIZE
I will only provide .lib and header file and I would expect it would work with at least windows compilers who knows from VC6 to VS2013 and gcc. I don't want to worry about that. Also even though I am using C++, I would like interface to be in C functions so they can be used more widely.