File tree Expand file tree Collapse file tree 1 file changed +7
-17
lines changed Expand file tree Collapse file tree 1 file changed +7
-17
lines changed Original file line number Diff line number Diff line change @@ -72,31 +72,21 @@ struct udev_list *udev_list_new(bool unique) {
7272 return list ;
7373}
7474
75- struct udev_list_entry * udev_list_entry_add (struct udev_list * list , const char * _name , const char * _value ) {
75+ struct udev_list_entry * udev_list_entry_add (struct udev_list * list , const char * name , const char * value ) {
7676 _cleanup_ (udev_list_entry_freep ) struct udev_list_entry * entry = NULL ;
77- _cleanup_free_ char * name = NULL , * value = NULL ;
7877
7978 assert (list );
80- assert (_name );
79+ assert (name );
8180
82- name = strdup ( _name );
83- if (!name )
81+ entry = new0 ( struct udev_list_entry , 1 );
82+ if (!entry )
8483 return NULL ;
8584
86- if (_value ) {
87- value = strdup (_value );
88- if (!value )
89- return NULL ;
90- }
91-
92- entry = new (struct udev_list_entry , 1 );
93- if (!entry )
85+ if (strdup_to (& entry -> name , name ) < 0 )
9486 return NULL ;
9587
96- * entry = (struct udev_list_entry ) {
97- .name = TAKE_PTR (name ),
98- .value = TAKE_PTR (value ),
99- };
88+ if (strdup_to (& entry -> value , value ) < 0 )
89+ return NULL ;
10090
10191 if (list -> unique ) {
10292 udev_list_entry_free (hashmap_get (list -> unique_entries , entry -> name ));
You can’t perform that action at this time.
0 commit comments