linux: please valgrind, free memory at exit
Free the memory that is used to store the new argv and envp. It's not strictly necessary (the OS is going to reclaim the memory anyway) but it makes the output from valgrind a lot less noisy.
This commit is contained in:
parent
45b5e79f8e
commit
5e09e1b57e
@ -57,6 +57,7 @@
|
||||
#endif
|
||||
|
||||
static char buf[MAXPATHLEN + 1];
|
||||
static void* args_mem;
|
||||
|
||||
static struct {
|
||||
char *str;
|
||||
@ -69,6 +70,12 @@ static void read_times(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||
static unsigned long read_cpufreq(unsigned int cpunum);
|
||||
|
||||
|
||||
__attribute__((destructor))
|
||||
static void free_args_mem(void) {
|
||||
free(args_mem); /* keep valgrind happy */
|
||||
}
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
|
||||
loop->inotify_watchers = NULL;
|
||||
loop->inotify_fd = -1;
|
||||
@ -147,11 +154,12 @@ char** uv_setup_args(int argc, char** argv) {
|
||||
size += (argc + 1) * sizeof(char **);
|
||||
size += (envc + 1) * sizeof(char **);
|
||||
|
||||
if ((s = (char *) malloc(size)) == NULL) {
|
||||
if (NULL == (s = malloc(size))) {
|
||||
process_title.str = NULL;
|
||||
process_title.len = 0;
|
||||
return argv;
|
||||
}
|
||||
args_mem = s;
|
||||
|
||||
new_argv = (char **) s;
|
||||
new_env = new_argv + argc + 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user