History

Merge commit '8ddc32629a6d6be77256694c9e322dde134609f3'

* commit '8ddc32629a6d6be77256694c9e322dde134609f3': mem: add av_strndup() for duplicating substrings Conflicts: libavutil/mem.c libavutil/mem.h libavutil/version.h

Michael Niedermayer committed 12 years ago

Commit c8571c62 parents 097bf14 8ddc3264 files · +34 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/mem.c +20 −0
  3. libavutil/mem.h +10 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2014-08-09 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182014-08-xx - xxxxxxx - lavu 54.03.0 - mem.h
19 Add av_strndup().
20
182014-xx-xx - xxxxxxx - lavu 54.02.0 - opt.h212014-xx-xx - xxxxxxx - lavu 54.02.0 - opt.h
19 Add av_opt_get_dict_val/set_dict_val with AV_OPT_TYPE_DICT to support22 Add av_opt_get_dict_val/set_dict_val with AV_OPT_TYPE_DICT to support
20 dictionary types being set as options.23 dictionary types being set as options.
libavutil/mem.c+20−0
@@ -267,6 +267,26 @@ char *av_strdup(const char *s) · 266 unmodified lines
267 return ptr;267 return ptr;
268}268}
269 269
270char *av_strndup(const char *s, size_t len)
271{
272 char *ret = NULL, *end;
273
274 if (!s)
275 return NULL;
276
277 end = memchr(s, 0, len);
278 if (end)
279 len = end - s;
280
281 ret = av_realloc(NULL, len + 1);
282 if (!ret)
283 return NULL;
284
285 memcpy(ret, s, len);
286 ret[len] = 0;
287 return ret;
288}
289
270void *av_memdup(const void *p, size_t size)290void *av_memdup(const void *p, size_t size)
271{291{
272 void *ptr = NULL;292 void *ptr = NULL;
libavutil/mem.h+10−0
@@ -240,6 +240,16 @@ av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t si · 239 unmodified lines
240 */240 */
241char *av_strdup(const char *s) av_malloc_attrib;241char *av_strdup(const char *s) av_malloc_attrib;
242 242
243/**
244 * Duplicate a substring of the string s.
245 * @param s string to be duplicated
246 * @param len the maximum length of the resulting string (not counting the
247 * terminating byte).
248 * @return Pointer to a newly-allocated string containing a
249 * copy of s or NULL if the string cannot be allocated.
250 */
251char *av_strndup(const char *s, size_t len) av_malloc_attrib;
252
243/**253/**
244 * Duplicate the buffer p.254 * Duplicate the buffer p.
245 * @param p buffer to be duplicated255 * @param p buffer to be duplicated
libavutil/version.h+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
56 */56 */
57 57
58#define LIBAVUTIL_VERSION_MAJOR 5458#define LIBAVUTIL_VERSION_MAJOR 54
59#define LIBAVUTIL_VERSION_MINOR 259#define LIBAVUTIL_VERSION_MINOR 3
60#define LIBAVUTIL_VERSION_MICRO 10060#define LIBAVUTIL_VERSION_MICRO 100
61 61
62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t