-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from brenhinkeller/withmallocarray
Support "withmallocarray"-type do-block syntax for most `MallocArray` constructors
- Loading branch information
Showing
4 changed files
with
194 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using StaticCompiler | ||
using StaticTools | ||
|
||
function withmallocarray(argc::Int, argv::Ptr{Ptr{UInt8}}) | ||
argc == 3 || return printf(stderrp(), c"Incorrect number of command-line arguments\n") | ||
rows = parse(Int64, argv, 2) # First command-line argument | ||
cols = parse(Int64, argv, 3) # Second command-line argument | ||
|
||
mzeros(rows, cols) do A | ||
printf(A) | ||
end | ||
mones(Int, rows, cols) do A | ||
printf(A) | ||
end | ||
mfill(3.141592, rows, cols) do A | ||
printf(A) | ||
end | ||
end | ||
|
||
# Attempt to compile | ||
path = compile_executable(withmallocarray, (Int64, Ptr{Ptr{UInt8}}), "./") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
796d1ea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release notes:
MallocArray
constructors so users can avoid having to ever manually callfree
(i.e., the "withmallocarray" trick)796d1ea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/64973
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: