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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user