Skip to content

Commit

Permalink
Add free(printbuffer) to Print module. Previous printBuffer=NULL, nev…
Browse files Browse the repository at this point in the history
…er freed the memory allocated.

git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/MathCoreOSMC@4101 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Björn Zachrisson committed Jun 30, 2009
1 parent 0fcf03a commit 937d394
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Compiler/runtime/printimpl.c
Expand Up @@ -35,7 +35,7 @@


#define GROWTH_FACTOR 1.4 /* According to some roumours of buffer growth */
#define INITIAL_BUFSIZE 1000 /* Seems reasonable */
#define INITIAL_BUFSIZE 4000 /* Seems reasonable */
char *buf = NULL;
char *errorBuf = NULL;

Expand Down Expand Up @@ -162,6 +162,7 @@ RML_BEGIN_LABEL(Print__clearBuf)
nfilled=0;
if (buf != 0) {
/* adrpo 2008-12-15 free the print buffer as it might have got quite big meantime */
free(buf);
buf = NULL;
cursize = 0;
}
Expand Down Expand Up @@ -272,7 +273,7 @@ int error_increase_buffer(void)
new_buf[0]='\0';
errorCursize = INITIAL_BUFSIZE;
} else {
new_buf = (char*)malloc(new_size =(int) (errorCursize * GROWTH_FACTOR*sizeof(char)));
new_buf = (char*)malloc((new_size =(int) (errorCursize * GROWTH_FACTOR))*sizeof(char));
if (new_buf == NULL) { return -1; }
memcpy(new_buf,errorBuf,errorCursize);
errorCursize = new_size;
Expand Down

0 comments on commit 937d394

Please sign in to comment.