Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename result variable for clarity. #157

Merged
merged 1 commit into from
May 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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