Skip to content

C: Support ListRepeat #2225

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

Merged
merged 2 commits into from
Jul 30, 2023
Merged

Conversation

ubaidsk
Copy link
Collaborator

@ubaidsk ubaidsk commented Jul 30, 2023

fixes #2221

@ubaidsk
Copy link
Collaborator Author

ubaidsk commented Jul 30, 2023

This PR needs to be rebased after merging/completion of #2224.

@ubaidsk
Copy link
Collaborator Author

ubaidsk commented Jul 30, 2023

Please note that the support for ListRepeat is only added for the C backend.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine.

Is the malloc part in C ever freed?

@ubaidsk ubaidsk force-pushed the c_support_list_repeat branch from d4cafbd to 1cb3eb0 Compare July 30, 2023 02:14
@ubaidsk
Copy link
Collaborator Author

ubaidsk commented Jul 30, 2023

Is the malloc part in C ever freed?

I think it is not freed ever.

$ git grep "_lfortran_free"
src/libasr/codegen/asr_to_llvm.cpp:    inline void call_lfortran_free(llvm::Function* fn, llvm::Type* llvm_data_type) {
src/libasr/codegen/asr_to_llvm.cpp:        std::string func_name = "_lfortran_free";
src/libasr/codegen/asr_to_llvm.cpp:    inline void call_lfortran_free_string(llvm::Function* fn) {
src/libasr/codegen/asr_to_llvm.cpp:                    call_lfortran_free(free_fn, llvm_data_type);
src/libasr/codegen/llvm_utils.cpp:            std::string func_name = "_lfortran_free";
src/libasr/runtime/lfortran_intrinsics.c:LFORTRAN_API void _lfortran_free(char* ptr) {
src/libasr/runtime/lfortran_intrinsics.h:LFORTRAN_API void _lfortran_free(char* ptr);

We should fix it soon. I think/guess it leads to memory leak.

@ubaidsk ubaidsk enabled auto-merge July 30, 2023 02:18
@ubaidsk ubaidsk merged commit b1001b6 into lcompilers:main Jul 30, 2023
@certik
Copy link
Contributor

certik commented Jul 30, 2023

Yes, it's time to fix all these.

@ubaidsk ubaidsk deleted the c_support_list_repeat branch July 30, 2023 03:49
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

Successfully merging this pull request may close these issues.

Code Generation Errors for C / C++ source code
2 participants