Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leaks #10

Open
vysocan opened this issue Apr 14, 2020 · 1 comment
Open

Possible memory leaks #10

vysocan opened this issue Apr 14, 2020 · 1 comment

Comments

@vysocan
Copy link

vysocan commented Apr 14, 2020

Hello,
first thanks for this library. I plan to use it as scripting language inside my STM32 project.

As MCUs are short on memory and generally have problems with alloc/free I'm using memory manager inside statically allocated array. This allows me to see how the memory is used or freed after tcl_eval() and tcl_destroy(). I found one problem which I yet do not understand. When I try to run this tcl:
= y";
I receive lexer error of course, but I see 2 not freed fragment inside memory:

=
y

I tried to add debug messages to all function that use tcl_malloc() or tcl_realloc, but I did not find any match to pointer address.

I quess there can be some addition to tcl_next(), somewhere after :

  } else if (*s == '"') {
    *q = !*q;
    *from = *to = s + 1;
    if (*q) {

to check for quote being closed. But it would be just to indicate to user what is the problem.

Not I'm not sure where it gets allocated, I have no idea how to free it.
Thanks for any advice.

@vysocan
Copy link
Author

vysocan commented Apr 16, 2020

OK simple enough solution to my problem:
tcl_list_free(list); tcl_free(cur);
Needs to be added in case of TERROR before exit of tcl_eval().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant