Skip to content

Commit 35c4a71

Browse files
committed
explain that bson_strncpy matches strncpy_s
1 parent 9f6365d commit 35c4a71

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libbson/doc/bson_strncpy.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ Parameters
2121
Description
2222
-----------
2323

24-
Copies up to ``size`` bytes from ``src`` into ``dst``. ``dst`` must be at least ``size`` bytes in size. A trailing ``\0`` will be set.
24+
Copies up to ``size`` bytes from ``src`` into ``dst``. ``dst`` must be at least ``size`` bytes in size. A trailing ``\0`` is always set.
2525

26+
Does nothing if ``size`` is zero.
27+
28+
``bson_strncpy`` matches the behavior of the C11 standard ``strncpy_s``, rather than ``strncpy``. This means that ``bson_strncpy`` always writes a null terminator to ``dst``, even if ``dst`` is too short to fit the entire string from ``src``. If there is additional space left in ``dst`` after copying ``src``, ``bson_strncpy`` does not fill the remaining space with null characters.

0 commit comments

Comments
 (0)