forked from Imagelibrary/rtems
2011-12-13 Sebastian Huber <sebastian.huber@embedded-brains.de>
* score/include/rtems/score/wkspace.h, score/src/wkstringduplicate.c: Changed parameter of _Workspace_String_duplicate() to avoid strnlen().
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2011-12-13 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||
|
||||
* score/include/rtems/score/wkspace.h, score/src/wkstringduplicate.c:
|
||||
Changed parameter of _Workspace_String_duplicate() to avoid strnlen().
|
||||
|
||||
2011-12-13 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* configure.ac: Check for getrusage.h decl.
|
||||
|
||||
@@ -102,18 +102,15 @@ void *_Workspace_Allocate_or_fatal_error(
|
||||
/**
|
||||
* @brief Duplicates the @a string with memory from the Workspace.
|
||||
*
|
||||
* If the @a string length exceeds @a maxlen, then the additional characters
|
||||
* will be discarded.
|
||||
*
|
||||
* @param[in] string Pointer to zero terminated string.
|
||||
* @param[in] maxlen Maximum length of the duplicated string.
|
||||
* @param[in] len Length of the string (equal to strlen(string)).
|
||||
*
|
||||
* @return NULL Not enough memory.
|
||||
* @return other Duplicated string.
|
||||
*/
|
||||
char *_Workspace_String_duplicate(
|
||||
const char *string,
|
||||
size_t maxlen
|
||||
size_t len
|
||||
);
|
||||
|
||||
#ifndef __RTEMS_APPLICATION__
|
||||
|
||||
@@ -24,15 +24,14 @@
|
||||
|
||||
char *_Workspace_String_duplicate(
|
||||
const char *string,
|
||||
size_t maxlen
|
||||
size_t len
|
||||
)
|
||||
{
|
||||
size_t n = strnlen(string, maxlen);
|
||||
char *dup = _Workspace_Allocate(n + 1);
|
||||
char *dup = _Workspace_Allocate(len + 1);
|
||||
|
||||
if (dup != NULL) {
|
||||
dup [n] = '\0';
|
||||
memcpy(dup, string, n);
|
||||
dup [len] = '\0';
|
||||
memcpy(dup, string, len);
|
||||
}
|
||||
|
||||
return dup;
|
||||
|
||||
Reference in New Issue
Block a user