Commit 1fc7d20dabbc285285eec1a46a80be179664072b

Daniel Mendler 2019-03-04T01:56:06

opponent/test.c: move ndraw to main.c

diff --git a/demo/main.c b/demo/main.c
index 5b57813..dc68ee9 100644
--- a/demo/main.c
+++ b/demo/main.c
@@ -3,6 +3,17 @@
 int mtest_opponent(void);
 int unit_tests(void);
 
+void ndraw(mp_int *a, const char *name)
+{
+   char buf[16000]; /* TODO: buffer might overflow! */
+
+   printf("%s: ", name);
+   mp_toradix(a, buf, 10);
+   printf("%s\n", buf);
+   mp_toradix(a, buf, 16);
+   printf("0x%s\n", buf);
+}
+
 int main(void)
 {
    srand(LTM_DEMO_RAND_SEED);
diff --git a/demo/opponent.c b/demo/opponent.c
index 329ed3f..b52ff72 100644
--- a/demo/opponent.c
+++ b/demo/opponent.c
@@ -1,17 +1,5 @@
 #include "shared.h"
 
-/* TODO: Duplicate ndraw in test.c */
-static void ndraw(mp_int *a, const char *name)
-{
-   char buf[16000]; /* TODO: buffer might overflow! */
-
-   printf("%s: ", name);
-   mp_toradix(a, buf, 10);
-   printf("%s\n", buf);
-   mp_toradix(a, buf, 16);
-   printf("0x%s\n", buf);
-}
-
 static void draw(mp_int *a)
 {
    ndraw(a, "");
diff --git a/demo/shared.h b/demo/shared.h
index 4481931..7be8e86 100644
--- a/demo/shared.h
+++ b/demo/shared.h
@@ -24,3 +24,5 @@
 #endif
 
 #include "tommath.h"
+
+void ndraw(mp_int*, const char*);
diff --git a/demo/test.c b/demo/test.c
index d62b7f3..346f571 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -1,17 +1,5 @@
 #include "shared.h"
 
-/* TODO: Duplicate ndraw in opponent.c */
-static void ndraw(mp_int *a, const char *name)
-{
-   char buf[16000]; /* TODO: buffer might overflow! */
-
-   printf("%s: ", name);
-   mp_toradix(a, buf, 10);
-   printf("%s\n", buf);
-   mp_toradix(a, buf, 16);
-   printf("0x%s\n", buf);
-}
-
 static int test_trivial_stuff(void) {
    mp_int a, b, c, d;
    if (mp_init_multi(&a, &b, &c, &d, NULL)!= MP_OKAY) {