re-reduce scope of temp variable (#175)

follow up to #172
This commit is contained in:
William Woodall 2017-11-08 08:16:42 -08:00 committed by GitHub
parent f7d7df6d69
commit ffcfc34890
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,12 +147,11 @@ rcl_node_init(
local_namespace_ = "/"; local_namespace_ = "/";
} }
char * temp = NULL;
// If the namespace does not start with a /, add one. // If the namespace does not start with a /, add one.
if (namespace_length > 0 && namespace_[0] != '/') { if (namespace_length > 0 && namespace_[0] != '/') {
// TODO(wjwwood): replace with generic strcat that takes an allocator once available // TODO(wjwwood): replace with generic strcat that takes an allocator once available
// length + 2, because new leading / and terminating \0 // length + 2, because new leading / and terminating \0
temp = (char *)allocator->allocate(namespace_length + 2, allocator->state); char * temp = (char *)allocator->allocate(namespace_length + 2, allocator->state);
RCL_CHECK_FOR_NULL_WITH_MSG( RCL_CHECK_FOR_NULL_WITH_MSG(
temp, "allocating memory failed", return RCL_RET_BAD_ALLOC, *allocator); temp, "allocating memory failed", return RCL_RET_BAD_ALLOC, *allocator);
temp[0] = '/'; temp[0] = '/';