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

Export a Free method to release returned markup text #330

Closed
darianmiller opened this issue Jan 25, 2020 · 3 comments
Closed

Export a Free method to release returned markup text #330

darianmiller opened this issue Jan 25, 2020 · 3 comments

Comments

@darianmiller
Copy link

When attempting to use a statically linked DLL, there should be a proper way of releasing the memory allocated for the returned markup text.

This could be as simple as a new export in cmark.h
CMARK_EXPORT
void freemarkup(void *ptr);

And in cmark.c:
void freemarkup(void *ptr) { free(ptr); }

Otherwise the calling parent process needs to release memory created by a child DLL, likely using different memory managers. In my case, calling the DLL from a Delphi application.

@darianmiller
Copy link
Author

I started looking into the cmark-gfm project and it has an export which would work to satisfy this request:

CMARK_GFM_EXPORT
cmark_mem *cmark_get_default_mem_allocator();

@jgm
Copy link
Member

jgm commented Feb 4, 2020

@nwellnhof - what do you think, should we export something like this too?

@nwellnhof
Copy link
Contributor

To be more precise, this issue arises on Windows if you link the cmark DLL to the CRT (C library) statically. It should already be possible to work around this issue by using a custom memory allocator. Exposing the default allocator is a good idea nevertheless.

@jgm jgm closed this as completed in fdbdbf7 Feb 9, 2020
QuietMisdreavus pushed a commit to swiftlang/swift-cmark that referenced this issue Jul 26, 2023
warning: passing argument 1 of ‘validate_protocol’ discards ‘const’ qualifier from pointer target type
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

3 participants