File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,13 @@ int thread__init_maps(struct thread *thread, struct machine *machine)
39
39
40
40
struct thread * thread__new (pid_t pid , pid_t tid )
41
41
{
42
- char * comm_str ;
43
- struct comm * comm ;
44
42
RC_STRUCT (thread ) * _thread = zalloc (sizeof (* _thread ));
45
43
struct thread * thread ;
46
44
47
45
if (ADD_RC_CHK (thread , _thread ) != NULL ) {
46
+ struct comm * comm ;
47
+ char comm_str [32 ];
48
+
48
49
thread__set_pid (thread , pid );
49
50
thread__set_tid (thread , tid );
50
51
thread__set_ppid (thread , -1 );
@@ -56,13 +57,8 @@ struct thread *thread__new(pid_t pid, pid_t tid)
56
57
init_rwsem (thread__namespaces_lock (thread ));
57
58
init_rwsem (thread__comm_lock (thread ));
58
59
59
- comm_str = malloc (32 );
60
- if (!comm_str )
61
- goto err_thread ;
62
-
63
- snprintf (comm_str , 32 , ":%d" , tid );
60
+ snprintf (comm_str , sizeof (comm_str ), ":%d" , tid );
64
61
comm = comm__new (comm_str , 0 , false);
65
- free (comm_str );
66
62
if (!comm )
67
63
goto err_thread ;
68
64
@@ -76,7 +72,7 @@ struct thread *thread__new(pid_t pid, pid_t tid)
76
72
return thread ;
77
73
78
74
err_thread :
79
- free (thread );
75
+ thread__delete (thread );
80
76
return NULL ;
81
77
}
82
78
You can’t perform that action at this time.
0 commit comments