This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (fixed patch) "%E" formatting for the humans


Mumit Khan wrote:
> 
> Corinna Vinschen <corinna.vinschen@cityweb.de> writes:
> > Mumit Khan wrote:
> > > [...]
> > > +               const int bufferlen = 189;
> > > [...]
> >
> > Consider other native language versions of the system. E.g. german
> > expressions are longer than english one's in the most cases.
> 
> The reason I limited the buffer size here is that I don't much about how
> the various char buffers are scattered throughout winsup, and didn't want
> to introduce a subtle bug due to overruns. My scheme is very safe in that
> it will get the proper error messages as long as it fits within the
> supplied buffer, and if it doesn't, fall back on the old-style message.
> 
> Someone with more experience with/time on winsup should be able to track
> all the various buffer sizes and then just adjust this limit accordingly.
> 
> Regards,
> Mumit

FormatMessage has an option, to allocate the needed buffer itself
(FORMAT_MESSAGE_ALLOCATE_BUFFER or similar). This buffer should
then be freed with LocalFree() after usage.
Would this be an alternative?

Regards,
Corinna