orb: avoid unnecessary string duplication of objname

This commit is contained in:
Beat Küng
2016-06-06 15:49:06 +02:00
committed by Lorenz Meier
parent 5125fc3a81
commit f5310ca51e
2 changed files with 2 additions and 18 deletions
+1 -9
View File
@@ -679,18 +679,12 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
*(adv->instance) = group_tries;
}
/* driver wants a permanent copy of the node name, so make one here */
objname = strdup(meta->o_name);
if (objname == nullptr) {
return -ENOMEM;
}
objname = meta->o_name; //no need for a copy, meta->o_name will never be freed or changed
/* driver wants a permanent copy of the path, so make one here */
devpath = strdup(nodepath);
if (devpath == nullptr) {
free((void *)objname);
return -ENOMEM;
}
@@ -699,7 +693,6 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
/* if we didn't get a device, that's bad */
if (node == nullptr) {
free((void *)objname);
free((void *)devpath);
return -ENOMEM;
}
@@ -726,7 +719,6 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
}
/* also discard the name now */
free((void *)objname);
free((void *)devpath);
} else {