History

avutil/mem: Add av_fast_mallocz()

Michael Niedermayer committed 10 years ago

Commit fc91eea1 parent 518742b4 files · +23 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/mem.c +4 −0
  3. libavutil/mem.h +15 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2015-11-18 - lavu 55.7.100 - mem.h
19+ Add av_fast_mallocz()
20+
1821 2015-10-29 - lavc 57.12.100 / 57.8.0 - avcodec.h
1922 xxxxxx - Deprecate av_free_packet(). Use av_packet_unref() as replacement,
2023 it resets the packet in a more consistent way.
libavutil/mem.c+4−0
@@ -501,3 +501,7 @@ void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size) · 500 unmodified lines
501501 ff_fast_malloc(ptr, size, min_size, 0);
502502 }
503503
504+void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
505+{
506+ ff_fast_malloc(ptr, size, min_size, 1);
507+}
libavutil/mem.h+15−0
@@ -384,6 +384,21 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); · 383 unmodified lines
384384 */
385385 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
386386
387+/**
388+ * Allocate a buffer, reusing the given one if large enough.
389+ *
390+ * All newly allocated space is initially cleared
391+ * Contrary to av_fast_realloc the current buffer contents might not be
392+ * preserved and on error the old buffer is freed, thus no special
393+ * handling to avoid memleaks is necessary.
394+ *
395+ * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
396+ * @param size size of the buffer *ptr points to
397+ * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
398+ * *size 0 if an error occurred.
399+ */
400+void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size);
401+
387402 /**
388403 * @}
389404 */
libavutil/version.h+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
5656 */
5757
5858 #define LIBAVUTIL_VERSION_MAJOR 55
59−#define LIBAVUTIL_VERSION_MINOR 6
59+#define LIBAVUTIL_VERSION_MINOR 7
6060 #define LIBAVUTIL_VERSION_MICRO 100
6161
6262 #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