[rtems commit] score: Simplify _Workspace_String_duplicate()

Sebastian Huber sebh at rtems.org
Wed Nov 21 17:19:09 UTC 2018


Module:    rtems
Branch:    master
Commit:    52c7cb1fdc69a032ca2859e1704412dc489ea0ac
Changeset: http://git.rtems.org/rtems/commit/?id=52c7cb1fdc69a032ca2859e1704412dc489ea0ac

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Nov 21 17:30:22 2018 +0100

score: Simplify _Workspace_String_duplicate()

---

 cpukit/score/src/wkstringduplicate.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/cpukit/score/src/wkstringduplicate.c b/cpukit/score/src/wkstringduplicate.c
index 647d1f4..ff6f973 100644
--- a/cpukit/score/src/wkstringduplicate.c
+++ b/cpukit/score/src/wkstringduplicate.c
@@ -30,15 +30,16 @@
 
 char *_Workspace_String_duplicate(
   const char *string,
-  size_t len
+  size_t      len
 )
 {
-  char *dup = _Workspace_Allocate(len + 1);
+  char *dup;
 
-  if (dup != NULL) {
-    dup [len] = '\0';
-    memcpy(dup, string, len);
+  dup = _Workspace_Allocate( len + 1 );
+  if ( dup == NULL ) {
+    return NULL;
   }
 
-  return dup;
+  dup[ len ] = '\0';
+  return memcpy( dup, string, len );
 }




More information about the vc mailing list