Skip to content

Commit

Permalink
Merge pull request #23305 from musm/patch-10
Browse files Browse the repository at this point in the history
Use a StringVector buffer for strftime
  • Loading branch information
StefanKarpinski authored Aug 24, 2017
2 parents 9f04577 + 685e7c9 commit 9fd7718
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ library.
strftime(t) = strftime("%c", t)
strftime(fmt::AbstractString, t::Real) = strftime(fmt, TmStruct(t))
function strftime(fmt::AbstractString, tm::TmStruct)
timestr = Vector{UInt8}(128)
timestr = Base.StringVector(128)
n = ccall(:strftime, Int, (Ptr{UInt8}, Int, Cstring, Ptr{TmStruct}),
timestr, length(timestr), fmt, &tm)
if n == 0
return ""
end
return String(timestr[1:n])
return String(resize!(timestr,n))
end

"""
Expand Down

0 comments on commit 9fd7718

Please sign in to comment.