Memory Leak warning if you use *Cstring parameters

TIP: Clarion 11 and earlier.
PTSS: 42786 (visible, and has example program)

Passing a *Cstring into a Procedure or Method, then doing an empty CASE on the parameter results in a memory leak.
eg

Proc1  procedure(*cstring pName) ! change type to anything else, no leak
  code
  case pName           ! remove the empty CASE statement, no leak
  end

The above code leaks the length of the pName parameter.

Hi Bruce,

To be fair the Help states that the OF clause is mandatory…

CASE condition
OF expression [ TO expression ]
statements
[ OROF expression [ TO expression ] ]
statements
[ ELSE ]
statements
END

the OROF TO and ELSE clauses can be omitted - but not the OF

Graham

True, but then it’s not a compiler leak error, it’s a compiler syntax-error error :slight_smile:

Hi Bruce,

I reported a memory leak to SV a few years ago related to the CASE statement.

I found that some template generated code could under certain circumstances generate a CASE structure without any “OF” statements (depending on user template input). In this scenario the leak occurred - it seems its never been addressed :frowning:

Regards,

Andy

yes, same thing as I found, but only if parameter is a *CSTRING and only if the CASE is on that Parameter. Do you have a PTSS reference for it?

I took a look earlier for the PTSS number but can’t find it? I could have swore I raised it on that system - maybe it was a direct email? I know I also raised it on the usergroups too - just so others could be made aware of it and work around accordingly…

In my tests, I don’t think it was related to a parameter, just a straight forward CASE END (without any OF statements) - I seem to remember 4k leaking??

It’s very specific now - has to be CASE Parameter, and the Parameter has to be a *Cstring. Leaks the size of the parameter string. So maybe yours was fixed, but this is an edge case…

That’s good news if it is fixed. It was quite a while ago - maybe as far back as C8 / C9

Cheers, Andy