Browse Source

MT#55283 add extra bencode_strdup* primitives

Change-Id: I54e108d276ebdb449227902efdaaf996d6c799a0
pull/1897/head
Richard Fuchs 11 months ago
parent
commit
113ae25a3c
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      include/bencode.h

+ 15
- 0
include/bencode.h View File

@ -377,6 +377,21 @@ INLINE str bencode_strdup_str(bencode_buffer_t *buf, const char *s) {
return o;
}
INLINE str bencode_str_strdup(bencode_buffer_t *buf, const str *s) {
str o = *s;
o.s = bencode_buffer_alloc(buf, o.len);
memcpy(o.s, s->s, o.len);
return o;
}
INLINE str *bencode_str_str_dup(bencode_buffer_t *buf, const str *s) {
str *o = bencode_buffer_alloc(buf, sizeof(*o));
*o = *s;
o->s = bencode_buffer_alloc(buf, o->len);
memcpy(o->s, s->s, o->len);
return o;
}
INLINE bencode_item_t *bencode_dictionary_add(bencode_item_t *dict, const char *key, bencode_item_t *val) {
if (!key)
return NULL;


Loading…
Cancel
Save