Skip to content

Commit

Permalink
Allow globally managing a default allocator to coordinate downstream …
Browse files Browse the repository at this point in the history
…packages
  • Loading branch information
quinnj committed May 31, 2024
1 parent 3fd0380 commit 9282c20
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/LibAwsCommon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,23 @@ for name in names(@__MODULE__; all=true)
@eval export $name
end

function init(allocator=aws_default_allocator())
const DEFAULT_AWS_ALLOCATOR = Ref{Ptr{aws_allocator}}(C_NULL)

function default_aws_allocator()
if DEFAULT_AWS_ALLOCATOR[] == C_NULL
DEFAULT_AWS_ALLOCATOR[] = aws_default_allocator()
end
return DEFAULT_AWS_ALLOCATOR[]
end

function set_default_aws_allocator!(allocator)
DEFAULT_AWS_ALLOCATOR[] = allocator
return
end

export default_aws_allocator, set_default_aws_allocator!

function init(allocator=default_aws_allocator())
aws_common_library_init(allocator)
return
end
Expand Down

0 comments on commit 9282c20

Please sign in to comment.