Re:What If I Don't Actually Like My Users? (2008)
by xyzzy123 on Friday June 03, 2016 @12:42AM
(#11828355)
Lots of win32 API calls work this way ><
[ Parent
| on HN ]
Re:What If I Don't Actually Like My Users? (2008)
by userbinator on Friday June 03, 2016 @08:02AM
(#11829787)
Win32 actually gives you a way of getting lengths most of the time, like this example:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
... but the corresponding POSIX one doesn't:
http://pubs.opengroup.org/onlinepubs/009695399/functions/get...
http://insanecoding.blogspot.ca/2007/11/pathmax-simply-isnt....
Re:What If I Don't Actually Like My Users? (2008)
by roel_v on Friday June 03, 2016 @03:34AM
(#11828898)
Like which one? Pretty much every single one I know, you pass a buffer and a pointer to a buffer size; the first time you call with buffer NULL and the required buffer size is put in the buffer size; then you allocate the buffer and call again with the proper buffer allocated.
Re:What If I Don't Actually Like My Users? (2008)
by xyzzy123 on Friday June 03, 2016 @05:32AM
(#11829217)
QueryDosDevice? You're right that mostly length is passed back, but esp in libs you get this problem you pass memory you own, some underlying function fails with "buffer too small", but buffer length was not in/out in the interface. Places where this can happen are not always obvious from reading the msdn.
Re:What If I Don't Actually Like My Users? (2008)
by xjia on Friday June 03, 2016 @01:38AM
(#11828551)
I remember doing similar things when using ReadProcessMemory https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
Re:What If I Don't Actually Like My Users? (2008)
by mnarayan01 on Friday June 03, 2016 @12:57AM
(#11828412)
IIRC, those generally take a pointer to the buffer length, and return an error code and populate the parameter if it's too small.