Browse Source

fixed bug with dynamic string where it wouldn't set the capacity properly

jp9000 12 years ago
parent
commit
0c3ed3ceca
1 changed files with 6 additions and 4 deletions
  1. 6 4
      libobs/util/dstr.h

+ 6 - 4
libobs/util/dstr.h

@@ -153,8 +153,9 @@ static inline void dstr_init(struct dstr *dst)
 
 static inline void dstr_init_move_array(struct dstr *dst, char *str)
 {
-	dst->array = str;
-	dst->len = (!str) ? 0 : strlen(str);
+	dst->array    = str;
+	dst->len      = (!str) ? 0 : strlen(str);
+	dst->capacity = dst->len + 1;
 }
 
 static inline void dstr_init_move(struct dstr *dst, struct dstr *src)
@@ -193,8 +194,9 @@ static inline void dstr_array_free(struct dstr *array, const size_t count)
 static inline void dstr_move_array(struct dstr *dst, char *str)
 {
 	dstr_free(dst);
-	dst->array = str;
-	dst->len = (!str) ? 0 : strlen(str);
+	dst->array    = str;
+	dst->len      = (!str) ? 0 : strlen(str);
+	dst->capacity = dst->len + 1;
 }
 
 static inline void dstr_move(struct dstr *dst, struct dstr *src)