From 270fbc433de6bec0811f9e2ade4e37def34439f2 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Mon, 11 Aug 2025 14:27:22 +0200 Subject: [PATCH 1/2] policies/coding-style.md: replace OPENSSL_malloc with OPENSSL_alloc_array [1] has introduced array allocation routines, and, since those are available, it is prudent to use where they are appropriate, like in this example. [1] https://github.com/openssl/openssl/pull/28059 Signed-off-by: Eugene Syromiatnikov --- policies/coding-style.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policies/coding-style.md b/policies/coding-style.md index 89d1958..9dc238a 100644 --- a/policies/coding-style.md +++ b/policies/coding-style.md @@ -174,7 +174,7 @@ use a variable when at all possible, to ensure that type changes are properly reflected: ```c -SOMETYPE *p = OPENSSL_malloc(sizeof(*p) * num_of_elements); +SOMETYPE *p = OPENSSL_alloc_array(num_of_elements, sizeof(*p)); ``` Do not add spaces around the inside of parenthesized expressions. From 38eb08ffe693521f31afb77e20b6739e446b538e Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Mon, 11 Aug 2025 14:29:22 +0200 Subject: [PATCH 2/2] policies/coding-style.md: mention new memory allocation APIs Mention aligned, clear, and array allocation routines. Signed-off-by: Eugene Syromiatnikov --- policies/coding-style.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/policies/coding-style.md b/policies/coding-style.md index 9dc238a..00fe879 100644 --- a/policies/coding-style.md +++ b/policies/coding-style.md @@ -601,9 +601,10 @@ The [GNU cpp manual][8] deals with macros exhaustively. ## Chapter 10: Allocating memory OpenSSL provides many general purpose memory utilities, including, but -not limited to: `OPENSSL_malloc()`, `OPENSSL_zalloc()`, `OPENSSL_realloc()`, -`OPENSSL_memdup()`, `OPENSSL_strdup()` and `OPENSSL_free()`. -Please refer to the API documentation for further information about them. +not limited to: `OPENSSL_malloc()`, `OPENSSL_zalloc()`, `OPENSSL_alloc_array`, +`OPENSSL_aligned_alloc`, `OPENSSL_realloc()`, `OPENSSL_clear_realloc`, +`OPENSSL_memdup()`, `OPENSSL_strdup()`, and `OPENSSL_free()`. Please refer +to the API documentation for further information about them. ## Chapter 11: Function return values and names