Lines Matching +full:cs +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0
22 static struct comm_str *comm_str__get(struct comm_str *cs) in comm_str__get() argument
24 if (cs && refcount_inc_not_zero(&cs->refcnt)) in comm_str__get()
25 return cs; in comm_str__get()
30 static void comm_str__put(struct comm_str *cs) in comm_str__put() argument
32 if (cs && refcount_dec_and_test(&cs->refcnt)) { in comm_str__put()
34 rb_erase(&cs->rb_node, &comm_str_root); in comm_str__put()
36 zfree(&cs->str); in comm_str__put()
37 free(cs); in comm_str__put()
43 struct comm_str *cs; in comm_str__alloc() local
45 cs = zalloc(sizeof(*cs)); in comm_str__alloc()
46 if (!cs) in comm_str__alloc()
49 cs->str = strdup(str); in comm_str__alloc()
50 if (!cs->str) { in comm_str__alloc()
51 free(cs); in comm_str__alloc()
55 refcount_set(&cs->refcnt, 1); in comm_str__alloc()
57 return cs; in comm_str__alloc()
63 struct rb_node **p = &root->rb_node; in __comm_str__findnew()
73 * If we race with comm_str__put, iter->refcnt is 0 in __comm_str__findnew()
77 cmp = strcmp(str, iter->str); in __comm_str__findnew()
81 if (cmp < 0) in __comm_str__findnew()
82 p = &(*p)->rb_left; in __comm_str__findnew()
84 p = &(*p)->rb_right; in __comm_str__findnew()
91 rb_link_node(&new->rb_node, parent, p); in __comm_str__findnew()
92 rb_insert_color(&new->rb_node, root); in __comm_str__findnew()
99 struct comm_str *cs; in comm_str__findnew() local
102 cs = __comm_str__findnew(str, root); in comm_str__findnew()
105 return cs; in comm_str__findnew()
115 comm->start = timestamp; in comm__new()
116 comm->exec = exec; in comm__new()
118 comm->comm_str = comm_str__findnew(str, &comm_str_root); in comm__new()
119 if (!comm->comm_str) { in comm__new()
129 struct comm_str *new, *old = comm->comm_str; in comm__override()
133 return -ENOMEM; in comm__override()
136 comm->comm_str = new; in comm__override()
137 comm->start = timestamp; in comm__override()
139 comm->exec = true; in comm__override()
141 return 0; in comm__override()
146 comm_str__put(comm->comm_str); in comm__free()
152 return comm->comm_str->str; in comm__str()