Skip to content

Commit 91b2ce2

Browse files
author
Donatien Garnier
committed
Fix memory leak in TF guide
1 parent 428d10d commit 91b2ce2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/reference/TensorFlow.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ Here is what you will need to complete the guide:
6161
nano debug_log.cc
6262
6363
extern "C" void DebugLog(const char* s) {
64-
UnbufferedSerial pc(USBTX, USBRX,9600);
65-
FILE *out = fdopen(&pc,"w");
66-
fprintf(out, s);
64+
static UnbufferedSerial pc(USBTX, USBRX,9600);
65+
static FILE *out = nullptr;
66+
if(out == nullptr) {
67+
out = fdopen(&pc, "w");
68+
}
69+
fprintf(out, s);
6770
}
6871
```
6972
1. Build the project

0 commit comments

Comments
 (0)