Skip to content

Commit

Permalink
Rename result variable for clarity. (#157)
Browse files Browse the repository at this point in the history
Signed-off-by: Steven! Ragnarök <[email protected]>
  • Loading branch information
nuclearsandwich authored May 6, 2019
1 parent b2f16e8 commit d3e2762
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ char * rcutils_get_executable_name(rcutils_allocator_t allocator)

// Since the above memory may be static, and the caller may want to modify
// the argument, make and return a copy here.
char * basec = allocator.allocate(applen + 1, allocator.state);
if (NULL == basec) {
char * executable_name = allocator.allocate(applen + 1, allocator.state);
if (NULL == executable_name) {
return NULL;
}

Expand All @@ -75,28 +75,28 @@ char * rcutils_get_executable_name(rcutils_allocator_t allocator)
// We need an intermediate copy because basename may modify its arguments
char * intermediate = allocator.allocate(applen + 1, allocator.state);
if (NULL == intermediate) {
allocator.deallocate(basec, allocator.state);
allocator.deallocate(executable_name, allocator.state);
return NULL;
}
memcpy(intermediate, appname, applen);
intermediate[applen] = '\0';

char * bname = basename(intermediate);
size_t baselen = strlen(bname);
memcpy(basec, bname, baselen);
basec[baselen] = '\0';
memcpy(executable_name, bname, baselen);
executable_name[baselen] = '\0';
allocator.deallocate(intermediate, allocator.state);
#elif defined _WIN32 || defined __CYGWIN
errno_t err = _splitpath_s(appname, NULL, 0, NULL, 0, basec, applen, NULL, 0);
errno_t err = _splitpath_s(appname, NULL, 0, NULL, 0, executable_name, applen, NULL, 0);
if (err != 0) {
allocator.deallocate(basec, allocator.state);
allocator.deallocate(executable_name, allocator.state);
return NULL;
}
#else
#error "Unsupported OS"
#endif

return basec;
return executable_name;
}

#ifdef __cplusplus
Expand Down

0 comments on commit d3e2762

Please sign in to comment.