GoogleCloudPlatform / iot-device-sdk-embedded-c

Cloud IoT Device SDK for Connectivity to IoT Core.
Other
246 stars 82 forks source link

BSP MEM POSIX realloc impl NULL input ptr handling, diff. vs. C standard #125

Open atigyi opened 3 years ago

atigyi commented 3 years ago

The SDK BSP MEM's realloc implementation does not enforce C standard behaviour. This is required if the underlying platform's realloc function doesn't meet the standard. In this particular case the behaviour on NULL input ptr value differs from the standard (below) for Raspberry Pi / ARM architecture.

iot-device-sdk's POSIX realloc function impl.

realloc - memory reallocator : "If ptr is a null pointer, realloc() shall be equivalent to malloc() for the specified size." C realloc C standard definition.

Some more details

sridharan-8888 commented 3 years ago

Additional info on the issue, it seems to be related to 'memory_limitter'

atigyi commented 3 years ago

Indeed, this isn't C standard compatible. Did you conduct tests with if-null-return-null lines removed?