# Using ccall and pointer to pointer in linked list

**URL:** <https://discourse.julialang.org/t/using-ccall-and-pointer-to-pointer-in-linked-list/72041>\
**Category:** General Usage\
**Tags:** question, ccall, c\
**Created:** [November 25, 2021, 4:07am UTC](https://discourse.julialang.org/t/using-ccall-and-pointer-to-pointer-in-linked-list/72041 "2021-11-25T04:07:05Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![chkwon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chkwon/32/3632_2.png) [@chkwon](https://discourse.julialang.org/u/chkwon)\
**Post date:** [November 25, 2021, 6:55am UTC](https://discourse.julialang.org/t/using-ccall-and-pointer-to-pointer-in-linked-list/72041/3 "2021-11-25T06:55:39Z")

</div>

Thanks, @tomaklutfu. Indeed it shouldn’t be NULL.

The following worked:

```julia

list_ref = Ref{Ptr{Node}}()

ccall((:add_to_list, LIBLIST), Cvoid, (Ptr{Ptr{Node}}, Cint), list_ref, 10)
ccall((:add_to_list, LIBLIST), Cvoid, (Ptr{Ptr{Node}}, Cint), list_ref, 20)

list = unsafe_load(list_ref[])
@show list.value # 20

```

[This comment](https://discourse.julialang.org/t/what-is-the-correct-way-to-create-a-pointer-to-pointer/71442/3) was helpful.

---

_[View the full topic](https://discourse.julialang.org/t/using-ccall-and-pointer-to-pointer-in-linked-list/72041)._
