[FFmpeg-devel] [PATCH 01/10] ffserver.c: Replace av_malloc with av_mallocz_array

Stephan Holljes klaxa1337 at googlemail.com
Mon May 28 21:27:02 EEST 2018


Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
---
 ffserver.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 12c257f..5fc7c44 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -509,8 +509,8 @@ void *run_server(void *arg) {
     pthread_t *r_threads;
     pthread_t **w_threads_p;
     
-    pubs = av_mallocz(config->nb_streams * sizeof(struct PublisherContext*));
-    ifmt_ctxs = av_mallocz(config->nb_streams * sizeof(AVFormatContext*));
+    pubs = av_mallocz_array(config->nb_streams, sizeof(struct PublisherContext*));
+    ifmt_ctxs = av_mallocz_array(config->nb_streams, sizeof(AVFormatContext*));
     
     av_log_set_level(AV_LOG_INFO);
     
@@ -520,10 +520,10 @@ void *run_server(void *arg) {
     ainfo.httpd = &lavfhttpd;
     ainfo.config = config;
     
-    rinfos = av_mallocz(config->nb_streams * sizeof(struct ReadInfo));
-    winfos_p = av_mallocz(config->nb_streams * sizeof(struct WriteInfo*));
-    r_threads = av_mallocz(config->nb_streams * sizeof(pthread_t));
-    w_threads_p = av_mallocz(config->nb_streams * sizeof(pthread_t*));
+    rinfos = av_mallocz_array(config->nb_streams, sizeof(struct ReadInfo));
+    winfos_p = av_mallocz_array(config->nb_streams, sizeof(struct WriteInfo*));
+    r_threads = av_mallocz_array(config->nb_streams, sizeof(pthread_t));
+    w_threads_p = av_mallocz_array(config->nb_streams, sizeof(pthread_t*));
     
     for (stream_index = 0; stream_index < config->nb_streams; stream_index++) {
         struct PublisherContext *pub = NULL;
@@ -549,8 +549,8 @@ void *run_server(void *arg) {
 
         rinfos[stream_index] = rinfo;
 
-        w_threads = av_malloc(sizeof(pthread_t) * pub->nb_threads);
-        winfos = av_malloc(sizeof(struct WriteInfo) * pub->nb_threads);
+        w_threads = av_mallocz_array(pub->nb_threads, sizeof(pthread_t));
+        winfos = av_mallocz_array(pub->nb_threads, sizeof(struct WriteInfo));
 
         w_threads_p[stream_index] = w_threads;
         winfos_p[stream_index] = winfos;
@@ -608,7 +608,7 @@ int main(int argc, char *argv[])
         printf("No valid configurations parsed.\n");
         return 1;
     }
-    server_threads = av_malloc(nb_configs * sizeof(pthread_t));
+    server_threads = av_mallocz_array(nb_configs, sizeof(pthread_t));
     for (i = 0; i < nb_configs; i++) {
         config_dump(configs + i);
         pthread_create(&server_threads[i], NULL, run_server, configs + i);
-- 
2.16.2



More information about the ffmpeg-devel mailing list