Repository: Konstantin8105/c4go
Pull request #279 (2019-02-24 17:14:31)

CSTD: string.h: memcpy

codecov[bot]: # [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=h1) Report
> Merging [#279](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=desc) into [master](https://codecov.io/gh/Konstantin8105/c4go/commit/9731e931ebb8677bf334ac4eebbabcba49b07ec7?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Konstantin8105/c4go/pull/279/graphs/tree.svg?width=650&token=esH2rHXlZ2&height=150&src=pr)](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #279      +/-   ##
==========================================
+ Coverage   86.88%   86.88%   +<.01%     
==========================================
  Files         180      180              
  Lines        9825     9829       +4     
==========================================
+ Hits         8536     8540       +4     
  Misses        890      890              
  Partials      399      399
```


| [Impacted Files](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [program/definition\_function.go](https://codecov.io/gh/Konstantin8105/c4go/pull/279/diff?src=pr&el=tree#diff-cHJvZ3JhbS9kZWZpbml0aW9uX2Z1bmN0aW9uLmdv) | `89.53% <ø> (ø)` | :arrow_up: |
| [noarch/string.go](https://codecov.io/gh/Konstantin8105/c4go/pull/279/diff?src=pr&el=tree#diff-bm9hcmNoL3N0cmluZy5nbw==) | `92.85% <100%> (+0.43%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=footer). Last update [9731e93...9b90554](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

codecov[bot]: # [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=h1) Report
> Merging [#279](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=desc) into [master](https://codecov.io/gh/Konstantin8105/c4go/commit/9731e931ebb8677bf334ac4eebbabcba49b07ec7?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Konstantin8105/c4go/pull/279/graphs/tree.svg?width=650&token=esH2rHXlZ2&height=150&src=pr)](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #279      +/-   ##
==========================================
+ Coverage   86.88%   86.88%   +<.01%     
==========================================
  Files         180      180              
  Lines        9825     9829       +4     
==========================================
+ Hits         8536     8540       +4     
  Misses        890      890              
  Partials      399      399
```


| [Impacted Files](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [program/definition\_function.go](https://codecov.io/gh/Konstantin8105/c4go/pull/279/diff?src=pr&el=tree#diff-cHJvZ3JhbS9kZWZpbml0aW9uX2Z1bmN0aW9uLmdv) | `89.53% <ø> (ø)` | :arrow_up: |
| [noarch/string.go](https://codecov.io/gh/Konstantin8105/c4go/pull/279/diff?src=pr&el=tree#diff-bm9hcmNoL3N0cmluZy5nbw==) | `92.85% <100%> (+0.43%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=footer). Last update [9731e93...9b90554](https://codecov.io/gh/Konstantin8105/c4go/pull/279?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/README.md b/README.md
index bab696d..1e8f0b0 100644
--- a/README.md
+++ b/README.md
@@ -133,7 +133,7 @@ func main() {
             stddef.h	       2/6	        33.3%
              stdio.h	     33/46	        71.7%
             stdlib.h	     33/47	        70.2%
-            string.h	     12/24	          50%
+            string.h	     13/24	        54.2%
               time.h	      7/15	        46.7%
              wchar.h	      3/68	        4.41%
             wctype.h	      0/22	           0%
diff --git a/noarch/string.go b/noarch/string.go
index d7e6608..c185ded 100644
--- a/noarch/string.go
+++ b/noarch/string.go
@@ -167,3 +167,10 @@ func Memcmp(lhs []byte, rhs []byte, count uint32) int {
 	}
 	return 0
 }
+
+func Memcpy(dest, source []byte, num uint) []byte {
+	for i := 0; i < int(num); i++ {
+		dest[i] = source[i]
+	}
+	return nil
+}
diff --git a/program/definition_function.go b/program/definition_function.go
index 6c2b977..bc5cee8 100644
--- a/program/definition_function.go
+++ b/program/definition_function.go
@@ -260,6 +260,7 @@ var builtInFunctionDefinitions = map[string][]string{
 		"char * memset(char *, char, unsigned int) -> noarch.Memset",
 		"char * memmove(char *, char *, unsigned int) -> noarch.Memmove",
 		"int memcmp(const char *, const char *, unsigned int) -> noarch.Memcmp",
+		"void * memcpy(void *, const void *, size_t) -> noarch.Memcpy",
 	},
 	"stdlib.h": {
 		// stdlib.h


Test patch:
diff --git a/tests/string.c b/tests/string.c
index 7cf6d26..2bfe012 100644
--- a/tests/string.c
+++ b/tests/string.c
@@ -3,7 +3,7 @@
 
 int main()
 {
-    plan(39);
+    plan(40);
 
     diag("TODO: __builtin_object_size");
     // https://github.com/Konstantin8105/c4go/issues/359
@@ -162,6 +162,13 @@ int main()
         is_streq(strstr(str, "three"), "three");
         //TODO: NULL check in is_eq(strstr(str, "four") - str, 0);
     }
+	{
+		diag("memcpy");
+		char myname[] = "Pierre de Fermat";
+		char name[40]; 
+		memcpy ( name, myname, strlen(myname)+1 );
+		is_streq(name, myname);
+	}
 
     done_testing();
 }