mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-13 13:37:34 +08:00
uORB: Remove transfer of memory allocation ownership to CDev
- Allocate and free the node name in uORBDeviceNode. - Add protected build support by de-allocating the name with kmm_free, when running in kernel side. strdup allocates from the kernel heap in NuttX kernel space. - Remove the CDev::unregister_driver_and_memory(), it is no longer used Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Daniel Agar
parent
25c10eb124
commit
ce6147f570
@@ -99,19 +99,11 @@ int uORB::DeviceMaster::advertise(const struct orb_metadata *meta, bool is_adver
|
||||
*instance = group_tries;
|
||||
}
|
||||
|
||||
/* driver wants a permanent copy of the path, so make one here */
|
||||
const char *devpath = strdup(nodepath);
|
||||
|
||||
if (devpath == nullptr) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* construct the new node, passing the ownership of path to it */
|
||||
uORB::DeviceNode *node = new uORB::DeviceNode(meta, group_tries, devpath);
|
||||
uORB::DeviceNode *node = new uORB::DeviceNode(meta, group_tries, nodepath);
|
||||
|
||||
/* if we didn't get a device, that's bad, free the path too */
|
||||
/* if we didn't get a device, that's bad */
|
||||
if (node == nullptr) {
|
||||
free((void *)devpath);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user