Skip to content

Commit

Permalink
Align code for CSTR_STRING and CSTR_STRING_AS_ARRAY (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Jul 14, 2023
1 parent cd2ce74 commit a30cb13
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ccalls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ MakeString(val::String) = GC.@preserve val ccall((:MakeStringWithLen, libgap), G
#TODO: As soon as libgap provides :GAP_MakeStringWithLen, use it.

function CSTR_STRING(val::GapObj)
len = ccall((:GAP_LenString, libgap), Int, (Any,), val)
char_ptr = ccall((:GAP_CSTR_STRING, libgap), Ptr{UInt8}, (Any,), val)
len = ccall((:GAP_LenString, libgap), Culong, (Any,), val)
return deepcopy(unsafe_string(char_ptr, len))::String
end

function CSTR_STRING_AS_ARRAY(val::GapObj)::Vector{UInt8}
string_len = Int64(ccall((:GAP_LenString, libgap), Cuint, (Any,), val))
len = ccall((:GAP_LenString, libgap), Int, (Any,), val)
char_ptr = ccall((:GAP_CSTR_STRING, libgap), Ptr{UInt8}, (Any,), val)
return deepcopy(unsafe_wrap(Vector{UInt8}, char_ptr, string_len))
return deepcopy(unsafe_wrap(Vector{UInt8}, char_ptr, len))
end


Expand Down

0 comments on commit a30cb13

Please sign in to comment.