Changeset 06a8139 in rtems


Ignore:
Timestamp:
Dec 13, 2011, 10:06:53 AM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
257d8fd
Parents:
73699608
Message:

2011-12-13 Sebastian Huber <sebastian.huber@…>

  • score/include/rtems/score/wkspace.h, score/src/wkstringduplicate.c: Changed parameter of _Workspace_String_duplicate() to avoid strnlen().
Location:
cpukit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r73699608 r06a8139  
     12011-12-13      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * score/include/rtems/score/wkspace.h, score/src/wkstringduplicate.c:
     4        Changed parameter of _Workspace_String_duplicate() to avoid strnlen().
     5
    162011-12-13      Ralf Corsépius <ralf.corsepius@rtems.org>
    27
  • cpukit/score/include/rtems/score/wkspace.h

    r73699608 r06a8139  
    103103 * @brief Duplicates the @a string with memory from the Workspace.
    104104 *
    105  * If the @a string length exceeds @a maxlen, then the additional characters
    106  * will be discarded.
    107  *
    108105 * @param[in] string Pointer to zero terminated string.
    109  * @param[in] maxlen Maximum length of the duplicated string.
     106 * @param[in] len Length of the string (equal to strlen(string)).
    110107 *
    111108 * @return NULL Not enough memory.
     
    114111char *_Workspace_String_duplicate(
    115112  const char *string,
    116   size_t maxlen
     113  size_t len
    117114);
    118115
  • cpukit/score/src/wkstringduplicate.c

    r73699608 r06a8139  
    2525char *_Workspace_String_duplicate(
    2626  const char *string,
    27   size_t maxlen
     27  size_t len
    2828)
    2929{
    30   size_t n = strnlen(string, maxlen);
    31   char *dup = _Workspace_Allocate(n + 1);
     30  char *dup = _Workspace_Allocate(len + 1);
    3231
    3332  if (dup != NULL) {
    34     dup [n] = '\0';
    35     memcpy(dup, string, n);
     33    dup [len] = '\0';
     34    memcpy(dup, string, len);
    3635  }
    3736
Note: See TracChangeset for help on using the changeset viewer.