<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hello,</div><div class=""><br class=""></div><div class="">It looks you are trying to implement a hybrid solution a mix up of Erlang and C code for routing. Unless, I’ve not understood your question. I would either implement A* purely native or purely in Erlang. In both cases, I would target a data structure that best suites your problem and implementation techniques. </div><div class=""><br class=""></div><div class="">Let’s say, you’ve made decision to implement A* in C then I would design a NIF API to address problem of A* search rather then memory management. In this case the updateBlock routine becomes internal for your C code. </div><div class=""><br class=""></div><div class="">BTW, Have you consider to use Cpp and NIFpp wrapper for Erlang to integrate existed A* algorithms ?</div><div class=""><br class=""></div><div class="">Best Regards, </div><div class="">Dmitry</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 10 Jul 2017, at 20.03, skyman <<a href="mailto:cloudzen@163.com" class="">cloudzen@163.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div class="">Hi Dmitry,<br class=""><br class="">Thanks for your reply.<br class="">The map of our game is large(1000 * 1000 grids). If I use NIF to implement the A Star find path in C, can I allocate the map grid array(1000 * 1000) in C, and when map blocks changed, Erlang calls 'updateBlock' NIF to update the grid state in grid array in C?<br class=""><br class=""></div>Thanks!<br class=""><br class=""><br class=""><br class=""><div style="position:relative;zoom:1" class=""></div><div id="divNeteaseMailCard" class=""></div><br class="">At 2017-07-11 00:33:34, "Dmitry Kolesnikov" <<a href="mailto:dmkolesnikov@gmail.com" class="">dmkolesnikov@gmail.com</a>> wrote:<br class=""> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid" class=""><div class="">Hello,</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 10 Jul 2017, at 19.11, skyman <<a href="mailto:cloudzen@163.com" class="">cloudzen@163.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div class=""><span style="font-family: arial;" class="">Hi everybody,</span></div><div class=""><span style="font-family: arial;" class=""><br class=""></span></div><div class=""><span style="font-family: arial;" class="">Our game is using A Star </span><font face="arial" class="">algorithm to find path. For performance I want to write it in C language, and Erlang calls it by NIF. I don't know whether the map data is maintained in C or in Erlang. Can anyone tell me?<br class=""></font></div></div></div></blockquote><div class=""><br class=""></div><div class="">Map is native data structure. However, you need to use enif interface to interact with it. </div><div class=""><a href="http://erlang.org/doc/man/erl_nif.html#enif_get_map_value" class="">http://erlang.org/doc/man/erl_nif.html#enif_get_map_value</a></div><br class=""><blockquote type="cite" class=""><div class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div class=""><font face="arial" class="">In addition, is there any better solution than NIF?<br class=""></font></div></div></div></blockquote><div class=""><br class=""></div><div class="">I’ve used to solve a “routing” issues on pure Erlang using ETS, lists, etc. However, this mainly depends on your traffic, latency and size of routing tables. It is hard to give a straight forward answer not knowing this figures. </div><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div class=""><font face="arial" class=""><br class=""></font></div><div class=""><font face="arial" class="">Thanks very much!</font></div></div></div></blockquote></div><br class=""><div class="">Best Regards, </div><div class="">Dmitry</div></blockquote></div><br class=""><br class=""><span title="neteasefooter" class=""><div class=""> <br class="webkit-block-placeholder"></div></span></div></blockquote></div><br class=""></body></html>