From e61483790832db5a76b307b351260ab6ecbf7a79 Mon Sep 17 00:00:00 2001 From: Francois Date: Thu, 28 Mar 2024 14:23:43 -0400 Subject: [PATCH] Use standard print method on memory allocation failure. --- src/Utils.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Utils.h b/src/Utils.h index 255d602..a0335f7 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -55,7 +55,9 @@ class TempBuffer { TempBuffer(size_t _nElements=1) : nElements(_nElements) { buf=(bufType *)HS_MALLOC(nElements*sizeof(bufType)); if(buf==NULL){ - Serial.printf("\n\n*** FATAL ERROR: Requested allocation of %d bytes failed. Program Halting.\n\n",nElements*sizeof(bufType)); + Serial.print("\n\n*** FATAL ERROR: Requested allocation of "); + Serial.print(nElements*sizeof(bufType)); + Serial.print(" bytes failed. Program Halting.\n\n"); while(1); } } @@ -67,7 +69,9 @@ class TempBuffer { size_t addElements=va_arg(args,size_t); buf=(bufType *)HS_REALLOC(buf,(nElements+addElements)*sizeof(bufType)); if(buf==NULL){ - Serial.printf("\n\n*** FATAL ERROR: Requested allocation of %d bytes failed. Program Halting.\n\n",nElements*sizeof(bufType)); + Serial.print("\n\n*** FATAL ERROR: Requested allocation of "); + Serial.print(nElements*sizeof(bufType)); + Serial.print(" bytes failed. Program Halting.\n\n"); while(1); } memcpy(buf+nElements,addBuf,addElements*sizeof(bufType));