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

Use per-thread libxml2 global state on all platforms #15121

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/xml.cr
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,7 @@ module XML
end

protected def self.with_indent_tree_output(indent : Bool, &)
ptr = {% if flag?(:win32) %}
LibXML.__xmlIndentTreeOutput
{% else %}
pointerof(LibXML.xmlIndentTreeOutput)
{% end %}

ptr = LibXML.__xmlIndentTreeOutput
old, ptr.value = ptr.value, indent ? 1 : 0
begin
yield
Expand All @@ -122,12 +117,7 @@ module XML
end

protected def self.with_tree_indent_string(string : String, &)
ptr = {% if flag?(:win32) %}
LibXML.__xmlTreeIndentString
{% else %}
pointerof(LibXML.xmlTreeIndentString)
{% end %}

ptr = LibXML.__xmlTreeIndentString
old, ptr.value = ptr.value, string.to_unsafe
begin
yield
Expand Down
10 changes: 2 additions & 8 deletions src/xml/libxml2.cr
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ lib LibXML

fun xmlInitParser

# TODO: check if other platforms also support per-thread globals
{% if flag?(:win32) %}
fun __xmlIndentTreeOutput : Int*
fun __xmlTreeIndentString : UInt8**
{% else %}
$xmlIndentTreeOutput : Int
$xmlTreeIndentString : UInt8*
{% end %}
fun __xmlIndentTreeOutput : Int*
fun __xmlTreeIndentString : UInt8**

alias Dtd = Void*
alias Dict = Void*
Expand Down
Loading