sd-bus: store the strv size when extending it
So strv_push_with_size() doesn't have to recalculate the size every time.
This commit is contained in:
@@ -4331,6 +4331,7 @@ int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz) {
|
||||
_public_ int sd_bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
|
||||
char type;
|
||||
const char *contents, *s;
|
||||
size_t n;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
@@ -4347,9 +4348,10 @@ _public_ int sd_bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
n = strv_length(*l);
|
||||
/* sd_bus_message_read_basic() does content validation for us. */
|
||||
while ((r = sd_bus_message_read_basic(m, *contents, &s)) > 0) {
|
||||
r = strv_extend(l, s);
|
||||
r = strv_extend_with_size(l, &n, s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user