Changeset 6700ee2 in mainline for uspace/lib/libc/generic/string.c
- Timestamp:
- 2009-04-14T19:31:12Z (16 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
-
uspace/lib/libc/generic/string.c
r4482bc7 r6700ee2 36 36 #include <string.h> 37 37 #include <stdlib.h> 38 #include <assert.h> 38 39 #include <limits.h> 39 40 #include <ctype.h> … … 471 472 * 472 473 * @param dst Destination buffer. 473 * @param count Size of the destination buffer .474 * @param count Size of the destination buffer (must be > 0). 474 475 * @param src Source string. 475 476 */ … … 480 481 size_t dest_off; 481 482 482 /* No space for the NULL-terminator in the buffer. */ 483 if (size == 0) 484 return; 483 /* There must be space for a null terminator in the buffer. */ 484 assert(size > 0); 485 485 486 486 src_off = 0; … … 497 497 /** Copy size-limited substring. 498 498 * 499 * Copy source string @a src to destination buffer @a dest.500 * No more than @a size bytes are written. If the size of the output buffer501 * is at least one byte, the output string will always be well-formed, i.e.502 * null-terminated and containing only completecharacters.499 * Copy prefix of string @a src of max. size @a size to destination buffer 500 * @a dest. No more than @a size bytes are written. The output string will 501 * always be well-formed, i.e. null-terminated and containing only complete 502 * characters. 503 503 * 504 504 * No more than @a n bytes are read from the input string, so it does not … … 506 506 * 507 507 * @param dst Destination buffer. 508 * @param count Size of the destination buffer .508 * @param count Size of the destination buffer (must be > 0). 509 509 * @param src Source string. 510 * @param n Maximum number of bytes to read from @a src. 510 511 */ 511 512 void str_ncpy(char *dest, size_t size, const char *src, size_t n) … … 515 516 size_t dest_off; 516 517 517 /* No space for the null terminator in the buffer. */ 518 if (size == 0) 519 return; 518 /* There must be space for a null terminator in the buffer. */ 519 assert(size > 0); 520 520 521 521 src_off = 0;
Note:
See TracChangeset
for help on using the changeset viewer.