Shohei Yasutake / Mbed 2 deprecated koibumi2000

Dependencies:   fll mbed-rtos mbed

Revision:
5:130721ce29f7
Parent:
4:9ee673ca05ad
Child:
6:d0348b7a2f05
--- a/fll.cpp	Sat Feb 14 06:49:42 2015 +0000
+++ b/fll.cpp	Sat Feb 14 07:25:27 2015 +0000
@@ -23,7 +23,6 @@
 // TODO: without loop
 button_t Source::await()
 {
-    
     if (size == 0) {
         return 0;
     }
@@ -32,16 +31,22 @@
 }
 
 // ----
-// Flow
+// Pipe
 // ----
-button_t Flow::await()
+Pipe::Pipe(Source **srcs, int srcs_size) : Source(NULL, 0, 1) {
+    sources = srcs;
+    sources_size = srcs_size;
+}
+
+button_t Pipe::await()
 {
-    std::vector<button_t> bs;
-    for (int k = 0; k < sources.size(); k++) {
-        button_t b = sources[k]->await();
-        bs.push_back(b);
+    button_t *bs = (button_t*) malloc(sizeof(button_t) * sources_size);
+    for (int i = 0; i < sources_size; i++) {
+        bs[i] = sources[i]->await();
     }
-    return fold(bs);
+    button_t b = fold(bs, sources_size);
+    free(bs);
+    return b;
 }