diff mbox series

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

Message ID 20210522220904.7012-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] avutil/mem: make max_alloc_size an atomic type | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer May 22, 2021, 10:09 p.m. UTC
Signed-off-by: James Almer <jamrial@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 mbox series

Patch

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);
+
 /**
  * @}
  * @}