Browse Source

Firm up memory leak changes

The solution works well in my test cases. I removed the rem'd out code
and updated the change remarks. Also bumped the version number.
dev
Jon Foster 2 years ago
parent
commit
46f431a4d7
3 changed files with 4 additions and 28 deletions
  1. +3
    -26
      bwb_exp.c
  2. +0
    -1
      bwb_var.c
  3. +1
    -1
      bwbasic.c

+ 3
- 26
bwb_exp.c View File

@@ -2702,31 +2702,11 @@ buff_read_function (char *buffer, int *position, VariantType * X)
{ {
/* STRING */ /* STRING */
var_make (argn, StringTypeCode); var_make (argn, StringTypeCode);
/* CM-20211223 this is double allocating, squashing the
pointer from the calloc() within var_make(). The RAM! It
be leakin'! */
/*if ((argn->Value.String =
(StringType *) calloc (1, sizeof (StringType))) == NULL)
{
WARN_OUT_OF_MEMORY;
return RESULT_ERROR;
}*/
/* CM-20211223 plug RAM leak. var_make() allocs RAM. */
PARAM_LENGTH = T.Length; PARAM_LENGTH = T.Length;
/* CM-20211223 either we keep the buffer instead of making a
new one or we need to free it. See RELEASE_VARIANT below.
I'm unremm'ing PARAM_BUFFER and leaving RELEASE_VARIANT
disabled. */
/* CM-20211223 Fix the RAM leak. We keep the buffer instead
of making a new one and copying it. This is faster. */
PARAM_BUFFER = T.Buffer; PARAM_BUFFER = T.Buffer;
/*if ((PARAM_BUFFER =
(char *) calloc (T.Length + 1 /* NulChar *//* ,
sizeof (char))) == NULL)
{
WARN_OUT_OF_MEMORY;
return RESULT_ERROR;
}
bwb_memcpy (PARAM_BUFFER, T.Buffer, T.Length);
PARAM_BUFFER[PARAM_LENGTH] = NulChar;*/
/* add type to ParameterTypes */
if (ParameterCount < MAX_FARGS) if (ParameterCount < MAX_FARGS)
{ {
ParameterTypes |= (1 << ParameterCount); ParameterTypes |= (1 << ParameterCount);
@@ -2743,9 +2723,6 @@ buff_read_function (char *buffer, int *position, VariantType * X)
{ {
ParameterCount++; ParameterCount++;
} }
/* CM-20211223 see comment dated the same just above. I chose to
keep the buffer... wondering why these had been rem'd out... */
/* RELEASE_VARIANT( &T ); */
} }
while (buff_skip_seperator (buffer, &p)); while (buff_skip_seperator (buffer, &p));




+ 0
- 1
bwb_var.c View File

@@ -348,7 +348,6 @@ var_free (VariableType * variable)
variable->Value.String[j].length = 0; variable->Value.String[j].length = 0;
} }
free (variable->Value.String); free (variable->Value.String);
;
variable->Value.String = NULL; variable->Value.String = NULL;
} }
} }


+ 1
- 1
bwbasic.c View File

@@ -83,7 +83,7 @@ static char *Banner[] = {
" ## ## ## ## ## ## ## ## ##", " ## ## ## ## ## ## ## ## ##",
" ######## ## ## ###### #### ###### ", " ######## ## ## ###### #### ###### ",
" ", " ",
"Bywater BASIC Interpreter, version 3.20f ",
"Bywater BASIC Interpreter, version 3.20g ",
"Copyright (c) 1993, Ted A. Campbell ", "Copyright (c) 1993, Ted A. Campbell ",
"Copyright (c) 1995-1997 , Jon B. Volkoff ", "Copyright (c) 1995-1997 , Jon B. Volkoff ",
"Copyright (c) 2014-2017 , Howard Wulf, AF5NE ", "Copyright (c) 2014-2017 , Howard Wulf, AF5NE ",


Loading…
Cancel
Save