Skip to content

Commit

Permalink
Merge branch 'release/0.18'
Browse files Browse the repository at this point in the history
Ary Borenszweig committed Jun 24, 2016

Verified

This commit was signed with the committer’s verified signature. The key has expired.
2 parents c49f41a + a11133f commit 9cf6e06
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/compiler/crystal/codegen/codegen.cr
Original file line number Diff line number Diff line change
@@ -1895,16 +1895,19 @@ module Crystal

def array_malloc(type, count)
@malloc_fun ||= @main_mod.functions[MALLOC_NAME]?
size = trunc(type.size, LLVM::Int32)
count = trunc(count, LLVM::Int32)
size = builder.mul size, count
if malloc_fun = @malloc_fun
malloc_fun = check_main_fun MALLOC_NAME, malloc_fun
size = trunc(type.size, LLVM::Int32)
count = trunc(count, LLVM::Int32)
size = builder.mul size, count
pointer = call malloc_fun, size
memset pointer, int8(0), size
bit_cast pointer, type.pointer
else
builder.array_malloc(type, count)
pointer = builder.array_malloc(type, count)
void_pointer = bit_cast pointer, LLVM::VoidPointer
memset void_pointer, int8(0), size
pointer
end
end

0 comments on commit 9cf6e06

Please sign in to comment.