From c6ced4e623924d2eb8e25cb40f90c641fec950be Mon Sep 17 00:00:00 2001
From: Armando Luiz Nicolini Delgado <nicolui@inf.ufpr.br>
Date: Mon, 25 Apr 2022 13:01:11 -0300
Subject: [PATCH] =?UTF-8?q?/*=20Alterado=20forma=20de=20calcular=20n=C3=BA?=
 =?UTF-8?q?mero=20de=20d=C3=ADgitos=20em=20um=20n=C3=BAmero.=20=20=20=20No?=
 =?UTF-8?q?=20momento,=20um=20n=C3=BAmero=20m=C3=A1ximo=20de=206=20d=C3=AD?=
 =?UTF-8?q?gitos.=20=20=20=20Foi=20comentado=20o=20c=C3=A1lculo=20gen?=
 =?UTF-8?q?=C3=A9rico=20usando=20log(n)=20=20*/?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 utils/utils.c | 2 +-
 utils/utils.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/utils/utils.c b/utils/utils.c
index 9bab73c..fd406bc 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -28,7 +28,7 @@ double timestamp(void)
  */
 string_t markerName(string_t baseName, int n)
 {
-  string_t mark = (string_t) malloc( (strlen(baseName)+1) + ( (int) log10(n) + 1) + 1 );
+    string_t mark = (string_t) malloc( (strlen(baseName)+1) + numDigits(n) + 1 );
 
   sprintf(mark, "%s_%u", baseName,n);
 
diff --git a/utils/utils.h b/utils/utils.h
index 6e4dde8..09764d2 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -14,6 +14,9 @@ typedef char * string_t;
 #define ALIGN_32 __attribute__((aligned(32)))
 #define ALIGN_16 __attribute__((aligned(16)))
 
+// Número máximo de dígitos em um número
+#define numDigits(n)  6  // ( (int) log10(n) + 1 )
+
 // Macro para verificar de valor 'n' é potência de 2 ou não
 #define isPot2(n) (n && !(n & (n - 1)))
 
-- 
GitLab