title: Webassembly growing memory and importing malloc
body: <p>After reading the specifications I was trying to grow some memory and did the following:</p>
  
  <pre><code>(module
    (table 0 anyfunc)
    (memory $0 1)
    (export "memory" (memory $0))
    (export "f" (func $0))
    (func $0 (param $0 i32) (result i32)
      get_local $0
      grow_memory
    )
  )
  </code></pre>
  
  <p>Now I was hoping that if we input 10 that we have a page size multiple of 11, so something like:</p>
  
  <pre><code> (memory $0 1)
  </code></pre>
  
  <p>Becomes </p>
  
  <pre><code> (memory $0 11)
  </code></pre>
  
  <p>I had to add a return value since the stack wasnt emptied. Now I assume that the method returns something other than -1 if it succeeds right? In this case I think it works and I should have more pages.</p>
  
  <p>I know there is also the JS way but I prefer doing all this stuff directly inside WebAssembly. Interesting though is the fact that we can import C functions such as malloc, free, strcopy etc from "Env"..</p>
  
  <p>So my question is: is my approach for growing the memory correct? Should I import the C style modules instead? What is the relation between grow_memory and realloc(), or say the difference?</p>