Switch to using calloc on all calls to malloc where the memory isn't
initialized. For things like the mraa_board_t, not allocating all to zero
causes issues such as with the sub_platform member, where if that's not zero
mraa_get_platform_type will try to dereference a random memory location for the
sub_platform->platform_name, which can result in segmentation faults and other
issues.
Note that in some places where immediately after the malloc call is a copy
operation, there is no need for calloc, as all the memory gets overwritten
anyways, but in cases where there may or may not be memory written to (such as
in mraa_file_contains, with reading from a file), even though in most cases the
memory is overwritten, it could be the case that the read operation does
nothing, but the memory still has non-zero values, by virtue of the fact it
wasn't overwritten.
Signed-off-by: Ian Johnson <ijohnson@wolfram.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Since on most 3rd party breakout boards the i2c bus exposed is 1 and not 6, it
makes more sense to have that as the default i2c bus
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This works ok if executing the whole file but the node.js interactive
interpreter gets confused when yoy copy and paste the code
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
By default, CMake assumes both a C and C++ compiler are required.
This is not needed for mraa because it only provides C++ header
files. Note that if using SWIG you need one and if using node.js 3+ you'll need
a C++11 compiler
Signed-off-by: Pieterjan Camerlynck <pieterjan.camerlynck@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
First four pins (0 to 3) are now built-in FTDI GPIO/I2C pins
If i2c GPIO expander is detected, next 8 pins (4 to 11) are its GPIO
If i2c switch is detected an extra 4 i2c busses are added
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
mraa_adv_func_t->gpio_init_internal_replace() now has mraa_gpio_context
parameter so that override function can access both physical and logical
pin numbers.
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
The change allows to build shared libraries by default on Linux, while
respecting the requested library build type when the standard CMake flag
BUILD_SHARED_LIBS is defined.
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Uses ::Copy instead of ::New which creates an internal buffer with malloc. This
commit also removes some useless code done after exception is raised (so won't
ever be executed)
Signed-off-by: Eugene Bolshakov <pub@relvarsoft.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This is especailly true since we don't care about the outcome, or do we? We
probably should check errno for EEXIST and offer an error if the error is
something else
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Fix memory leak in mraa_iio_update_channels() and mraa_iio_get_channel_data().
In mraa_iio_update_channels(), we add checking for out of bound array access.
Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
- C API read/write integer functions changed to int to match C types
- C API now has close function to release resources acquired during init
- iio internal type isr_event() function now has args param in signature
- C++ API now supports events with handler interface and new data structure
- C and C++ examples updated to use API changes
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>