From 984c9c317a2da2e9b65f24aeb5c6268d75b6e306 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max.kellermann@gmail.com>
Date: Mon, 13 Mar 2023 12:01:21 +0100
Subject: [PATCH] pcm/Normalizer: add `noexcept`

---
 src/pcm/Normalizer.cxx | 20 +++++++++++++-------
 src/pcm/Normalizer.hxx | 15 ++++++++++-----
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/pcm/Normalizer.cxx b/src/pcm/Normalizer.cxx
index 1dbf40d57..d9d9cccbb 100644
--- a/src/pcm/Normalizer.cxx
+++ b/src/pcm/Normalizer.cxx
@@ -33,7 +33,8 @@ struct Compressor {
         unsigned int bufsz;
 };
 
-struct Compressor *Compressor_new(unsigned int history)
+struct Compressor *
+Compressor_new(unsigned int history) noexcept
 {
 	Compressor *obj = (Compressor *)malloc(sizeof(struct Compressor));
 	if (obj == nullptr)
@@ -53,7 +54,8 @@ struct Compressor *Compressor_new(unsigned int history)
         return obj;
 }
 
-void Compressor_delete(struct Compressor *obj)
+void
+Compressor_delete(struct Compressor *obj) noexcept
 {
 	if (obj->peaks)
 		free(obj->peaks);
@@ -64,7 +66,8 @@ void Compressor_delete(struct Compressor *obj)
 	free(obj);
 }
 
-static int *resizeArray(int *data, int newsz, int oldsz)
+static int *
+resizeArray(int *data, int newsz, int oldsz) noexcept
 {
         data = (int *)realloc(data, newsz*sizeof(int));
 	if (data == nullptr)
@@ -76,7 +79,8 @@ static int *resizeArray(int *data, int newsz, int oldsz)
         return data;
 }
 
-void Compressor_setHistory(struct Compressor *obj, unsigned int history)
+void
+Compressor_setHistory(struct Compressor *obj, unsigned int history) noexcept
 {
 	if (!history)
                 history = BUCKETS;
@@ -87,13 +91,15 @@ void Compressor_setHistory(struct Compressor *obj, unsigned int history)
         obj->bufsz = history;
 }
 
-struct CompressorConfig *Compressor_getConfig(struct Compressor *obj)
+struct CompressorConfig *
+Compressor_getConfig(struct Compressor *obj) noexcept
 {
         return &obj->prefs;
 }
 
-void Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
-                              unsigned int count)
+void
+Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
+			 unsigned int count) noexcept
 {
         struct CompressorConfig *prefs = Compressor_getConfig(obj);
 	int16_t *ap;
diff --git a/src/pcm/Normalizer.hxx b/src/pcm/Normalizer.hxx
index 2e0d14d56..0a4f1aeb1 100644
--- a/src/pcm/Normalizer.hxx
+++ b/src/pcm/Normalizer.hxx
@@ -16,19 +16,24 @@ struct CompressorConfig {
 struct Compressor;
 
 //! Create a new compressor (use history value of 0 for default)
-struct Compressor *Compressor_new(unsigned int history);
+struct Compressor *
+Compressor_new(unsigned int history) noexcept;
 
 //! Delete a compressor
-void Compressor_delete(struct Compressor *);
+void
+Compressor_delete(struct Compressor *) noexcept;
 
 //! Set the history length
-void Compressor_setHistory(struct Compressor *, unsigned int history);
+void
+Compressor_setHistory(struct Compressor *, unsigned int history) noexcept;
 
 //! Get the configuration for a compressor
-struct CompressorConfig *Compressor_getConfig(struct Compressor *);
+struct CompressorConfig *
+Compressor_getConfig(struct Compressor *) noexcept;
 
 //! Process 16-bit signed data
-void Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count);
+void
+Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count) noexcept;
 
 //! TODO: Compressor_Process_int32, Compressor_Process_float, others as needed