diff --git a/utils/utils.c b/utils/utils.c index 9bab73cc467e544cacc17ca7f89f41ced8cad3ce..fd406bc0da0127b0d687b96572470c568be6ee5c 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 6e4dde80e696d77fafcdf1c795bb3582160c4bbc..09764d2e8a4886567220e89271be6c9d394331ea 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)))