@@ -35,6 +35,10 @@ const _C_ON_SUBSCRIBE_COMPLETE = Ref{Ptr{Cvoid}}(C_NULL)
3535const _C_ON_UNSUBSCRIBE_COMPLETE = Ref {Ptr{Cvoid}} (C_NULL )
3636const _C_ON_RESUBSCRIBE_COMPLETE = Ref {Ptr{Cvoid}} (C_NULL )
3737const _C_ON_PUBLISH_COMPLETE = Ref {Ptr{Cvoid}} (C_NULL )
38+ const _C_AWS_MALLOC = Ref {Ptr{Cvoid}} (C_NULL )
39+ const _C_AWS_FREE = Ref {Ptr{Cvoid}} (C_NULL )
40+ const _C_AWS_REALLOC = Ref {Ptr{Cvoid}} (C_NULL )
41+ const _C_AWS_CALLOC = Ref {Ptr{Cvoid}} (C_NULL )
3842
3943function _release (; include_mem_tracer = isempty (get (ENV , " AWS_CRT_MEMORY_TRACING" , " " )))
4044 aws_thread_set_managed_join_timeout_ns (5e8 ) # 0.5 seconds
@@ -61,6 +65,8 @@ const advanced_use_note =
6165 " default so that you can bring your own native data if you need to. However, you are then responsible for the " *
6266 " memory management of that data."
6367
68+ include (" allocator.jl" )
69+
6470include (" AWSIO.jl" )
6571export EventLoopGroup
6672export get_or_create_default_event_loop_group
@@ -139,6 +145,10 @@ function __init__()
139145 )
140146 _C_ON_PUBLISH_COMPLETE[] =
141147 @cfunction (_c_on_publish_complete, Cvoid, (Ptr{aws_mqtt_client_connection}, Cuint, Cint, Ptr{Cvoid}))
148+ _C_AWS_MALLOC[] = @cfunction (_c_aws_malloc, Ptr{Cvoid}, (Ptr{aws_allocator}, Csize_t))
149+ _C_AWS_FREE[] = @cfunction (_c_aws_free, Cvoid, (Ptr{aws_allocator}, Ptr{Cvoid}))
150+ _C_AWS_REALLOC[] = @cfunction (_c_aws_realloc, Ptr{Cvoid}, (Ptr{aws_allocator}, Ptr{Cvoid}, Csize_t, Csize_t))
151+ _C_AWS_CALLOC[] = @cfunction (_c_aws_calloc, Ptr{Cvoid}, (Ptr{aws_allocator}, Csize_t, Csize_t))
142152
143153 _AWSCRT_ALLOCATOR[] = let level = get (ENV , " AWS_CRT_MEMORY_TRACING" , " " )
144154 if ! isempty (level)
@@ -152,6 +162,8 @@ function __init__()
152162 end
153163 frames_per_stack = parse (Int, strip (get (ENV , " AWS_CRT_MEMORY_TRACING_FRAMES_PER_STACK" , " 0" )))
154164 aws_mem_tracer_new (aws_default_allocator (), C_NULL , level, frames_per_stack)
165+ elseif get (ENV , " AWS_CRT_USE_JL_ALLOCATOR" , " " ) == " true"
166+ new_jl_allocator ()
155167 else
156168 aws_default_allocator ()
157169 end
0 commit comments