Silly question. Why does strncpy_s() fill the unused part of the destination
with 0xFD?
Cheers,
Jan
This is not a silly question. CRT does it on purpose. It helps you
during debugging, so you can easily see what bytes belong to what.
For more special memory values see here:
"Win32 Debug CRT Heap Internals"
http://www.nobugs.org/developer/win32/debug_crt_heap.html
Alex
I guess it does so in order to diagnose better when you are accessing the
memory there. This gives you a defined value that typically makes no sense,
so if you see it, you know that you did something wrong. It's the same as
with debug builds initialising ints to 0xcccccccc or malloc adding some
buffer range before and after the requested memory to track out-of-range
writes.
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
Hi Alan,
Is there a way to have the _s versions not try to be so "helpful" when a
buffer has been carefully zeroed for a good reason?
Cheers,
Jan
Yes. You have two choices:
1. Use _CrtSetDebugFillThreshold in ordert to affect debug version
of *_s string functions.
2. Use "unsafe" strncpy, which will pad the rest of the buffere
with zeroes.
HTH
Alex
On Tue, 17 Mar 2009 13:36:50 -0000, "Jan M" <ja...@jerseymail.co.uk>
wrote:
Thanks. _CrtSetDebugFillThreshold() is what I was looking for.
Cheers,
Jan
"Alex Blekhman" <tkfx....@yahoo.com> wrote in message
news:%234beSCx...@TK2MSFTNGP03.phx.gbl...