MT#56447 add bencode_strdup_str

Change-Id: I89bd03a9a926a1c5d399fe13eda592b46951bcdb
pull/1642/head
Richard Fuchs 3 years ago
parent 6678d15631
commit 50f09c33f5

@ -89,6 +89,9 @@ INLINE bencode_buffer_t *bencode_item_buffer(bencode_item_t *);
/* like strdup() but uses the bencode buffer to store the string */ /* like strdup() but uses the bencode buffer to store the string */
INLINE char *bencode_strdup(bencode_buffer_t *, const char *); INLINE char *bencode_strdup(bencode_buffer_t *, const char *);
/* ditto but inits a str object */
INLINE void bencode_strdup_str(bencode_buffer_t *, str *, const char *);
@ -378,6 +381,12 @@ INLINE char *bencode_strdup(bencode_buffer_t *buf, const char *s) {
return ret; return ret;
} }
INLINE void bencode_strdup_str(bencode_buffer_t *buf, str *o, const char *s) {
o->len = strlen(s);
o->s = bencode_buffer_alloc(buf, o->len);
memcpy(o->s, s, o->len);
}
INLINE bencode_item_t *bencode_dictionary_add(bencode_item_t *dict, const char *key, bencode_item_t *val) { INLINE bencode_item_t *bencode_dictionary_add(bencode_item_t *dict, const char *key, bencode_item_t *val) {
if (!key) if (!key)
return NULL; return NULL;

Loading…
Cancel
Save