[FFmpeg-devel] [PATCH 2/3] avutil/mem: add a function to retrieve the current max_alloc_size value

James Almer jamrial at gmail.com
Sun May 23 01:09:03 EEST 2021


Signed-off-by: James Almer <jamrial at gmail.com>
---
Missing APIChanges entry (Do i bump version? We're still in open ABI season).

 libavutil/mem.c |  4 ++++
 libavutil/mem.h | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index c12c24aa90..495eed880d 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -75,6 +75,10 @@ void av_max_alloc(size_t max){
     atomic_store_explicit(&max_alloc_size, max, memory_order_relaxed);
 }
 
+void av_max_alloc_get(size_t *max) {
+    *max = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
+}
+
 void *av_malloc(size_t size)
 {
     void *ptr = NULL;
diff --git a/libavutil/mem.h b/libavutil/mem.h
index e21a1feaae..322d6acb68 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -698,6 +698,19 @@ static inline int av_size_mult(size_t a, size_t b, size_t *r)
  */
 void av_max_alloc(size_t max);
 
+/**
+ * Get the maximum size that may be allocated in one block.
+ *
+ * The value returned by this function is effective for all libavutil's @ref
+ * lavu_mem_funcs "heap management functions."
+ *
+ * @param max Pointer where to store the value
+ *
+ * @see av_max_alloc()
+ *
+ */
+void av_max_alloc_get(size_t *max);
+
 /**
  * @}
  * @}
-- 
2.31.1



More information about the ffmpeg-devel mailing list