Skip to content

Commit

Permalink
Added c_calloc and c_realloc and updated docs accordingly.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamed2 committed Jan 24, 2014
1 parent c9447ac commit b0359a5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,8 @@ export
# C interface
c_free,
c_malloc,
c_calloc,
c_realloc,
cfunction,
cglobal,
disable_sigint,
Expand Down
2 changes: 2 additions & 0 deletions base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ end

c_free(p::Ptr) = ccall(:free, Void, (Ptr{Void},), p)
c_malloc(size::Integer) = ccall(:malloc, Ptr{Void}, (Csize_t,), size)
c_realloc(p::Ptr, size::Integer) = ccall(:realloc, Ptr{Void}, (Ptr{Void}, Csize_t), p, size)
c_calloc(num::Integer, size::Integer) = ccall(:calloc, Ptr{Void}, (Csize_t, Csize_t), num, size)
12 changes: 12 additions & 0 deletions doc/helpdb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7057,6 +7057,18 @@ popdisplay(d::Display)
"),

("C Interface","Base","c_calloc","c_calloc(num::Integer, size::Integer)
Call \"calloc\" from the C standard library.
"),

("C Interface","Base","c_realloc","c_realloc(addr::Ptr, size::Integer)
Call \"realloc\" from the C standard library.
"),

("C Interface","Base","c_free","c_free(addr::Ptr)
Call \"free\" from the C standard library.
Expand Down
10 changes: 9 additions & 1 deletion doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4844,10 +4844,18 @@ C Interface

Close shared library referenced by handle.

.. function:: c_malloc(size::Integer)
.. function:: c_malloc(size::Integer) -> Ptr{Void}

Call ``malloc`` from the C standard library.

.. function:: c_calloc(num::Integer, size::Integer) -> Ptr{Void}

Call ``calloc`` from the C standard library.

.. function:: c_realloc(addr::Ptr, size::Integer) -> Ptr{Void}

Call ``realloc`` from the C standard library.

.. function:: c_free(addr::Ptr)

Call ``free`` from the C standard library.
Expand Down

0 comments on commit b0359a5

Please sign in to comment.