Browse Source

Use static buffer. No leak now.

Steve Thielemann 5 years ago
parent
commit
80d87ab6cb
1 changed files with 2 additions and 10 deletions
  1. 2 10
      ODPrntf.c

+ 2 - 10
ODPrntf.c

@@ -71,7 +71,7 @@
 ODAPIDEF void ODVCALL od_printf(const char *pszFormat,...)
 {
    va_list pArgumentList;
-   static char *pszWorkBuffer = NULL;
+   static char pszWorkBuffer[WORK_BUFFER_SIZE];
    char *pchCurrent;
    char *pchStart;
    BOOL bNotFound;
@@ -85,15 +85,7 @@ ODAPIDEF void ODVCALL od_printf(const char *pszFormat,...)
 
    OD_API_ENTRY();
 
-   /* Allocate work buffer if none has been allocated yet. */
-   if(pszWorkBuffer == NULL &&
-      (pszWorkBuffer = malloc(WORK_BUFFER_SIZE)) == NULL)
-   {
-      /* If we are unable to allocate a buffer, return with a memory error. */
-      od_control.od_error = ERR_MEMORY;
-      OD_API_EXIT();
-      return;
-   }
+   /* Use static work buffer. */
 
    /* Copy the arguments after the format string. */
    va_start(pArgumentList, pszFormat);