From c13d430ac6ce48137bd3c576febbf1b8f0fe2625 Mon Sep 17 00:00:00 2001 From: Vinicius Dias Date: Thu, 11 Apr 2024 13:46:33 -0300 Subject: [PATCH] Creating function for PHP wrapper and freeing pointer --- wrappers/wrapper.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/wrappers/wrapper.php b/wrappers/wrapper.php index f96bb0fa6..4b68e2dc6 100644 --- a/wrappers/wrapper.php +++ b/wrappers/wrapper.php @@ -1,9 +1,19 @@ cmark_markdown_to_html($markdown, strlen($markdown), 0); + $html = FFI::string($pointerReturn); + FFI::free($pointerReturn); + + return $html; +} + $markdown = <<<'md' # First level title @@ -13,6 +23,4 @@ md; -$html = FFI::string($ffi->cmark_markdown_to_html($markdown, strlen($markdown), 0)); - -echo $html . PHP_EOL; +echo markdownToHtml($markdown) . PHP_EOL;