Private
Public Access
2
0

examples: Remove heap allocation from C++ examples

Small cleanup of MRAA C++ examples.  Switched from heap allocation to
stack allocation when possible.  This simplifies the samples since it
removes the need for explicit memory management.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2017-08-08 13:55:23 -07:00
parent d50b646c35
commit 1217c5c034
7 changed files with 29 additions and 47 deletions

View File

@@ -39,11 +39,11 @@ interrupt(void* args)
int
main()
{
mraa::Gpio* x = new mraa::Gpio(6);
mraa::Gpio x(6);
x->dir(mraa::DIR_IN);
x.dir(mraa::DIR_IN);
x->isr(mraa::EDGE_BOTH, &interrupt, NULL);
x.isr(mraa::EDGE_BOTH, &interrupt, NULL);
int i = 100;
for (; i > 0; --i) {
@@ -55,6 +55,5 @@ main()
sleep(1);
}
delete x;
return MRAA_SUCCESS;
}