Changeset 6700ee2 in mainline for kernel/generic/src/lib/string.c
- Timestamp:
- 2009-04-14T19:31:12Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 17646b1
- Parents:
- 4482bc7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/lib/string.c
r4482bc7 r6700ee2 109 109 #include <errno.h> 110 110 #include <align.h> 111 #include <debug.h> 111 112 112 113 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 537 538 * 538 539 * @param dst Destination buffer. 539 * @param count Size of the destination buffer .540 * @param count Size of the destination buffer (must be > 0). 540 541 * @param src Source string. 541 542 */ … … 546 547 size_t dest_off; 547 548 548 /* No space for the NULL-terminator in the buffer. */ 549 if (size == 0) 550 return; 549 /* There must be space for a null terminator in the buffer. */ 550 ASSERT(size > 0); 551 551 552 552 src_off = 0; … … 563 563 /** Copy size-limited substring. 564 564 * 565 * Copy source string @a src to destination buffer @a dest.566 * No more than @a size bytes are written. If the size of the output buffer567 * is at least one byte, the output string will always be well-formed, i.e.568 * null-terminated and containing only completecharacters.565 * Copy prefix of string @a src of max. size @a size to destination buffer 566 * @a dest. No more than @a size bytes are written. The output string will 567 * always be well-formed, i.e. null-terminated and containing only complete 568 * characters. 569 569 * 570 570 * No more than @a n bytes are read from the input string, so it does not … … 572 572 * 573 573 * @param dst Destination buffer. 574 * @param count Size of the destination buffer .574 * @param count Size of the destination buffer (must be > 0). 575 575 * @param src Source string. 576 * @param n Maximum number of bytes to read from @a src. 576 577 */ 577 578 void str_ncpy(char *dest, size_t size, const char *src, size_t n) … … 581 582 size_t dest_off; 582 583 583 /* No space for the null terminator in the buffer. */ 584 if (size == 0) 585 return; 584 /* There must be space for a null terminator in the buffer. */ 585 ASSERT(size > 0); 586 586 587 587 src_off = 0;
Note:
See TracChangeset
for help on using the changeset viewer.