title: how to deallocate stack in ucontext* , linux?
body: <p>so I am trying to deallocate the context.</p>
  
  <p>Here is how I created context</p>
  
  <pre><code>ucontext* uPtr = new ucontext;
  getcontext(uPtr);
  
  char* stack = new char[STACK_SIZE];
  uPtr-&gt;uc_stack.ss_sp = stack;
  uPtr-&gt;uc_stack.ss_size = STACK_SIZE;
  uPtr-&gt;uc_stack.ss_flags = 0;
  uPtr-&gt;uc_link = NULL;
  
  makecontext(uPtr, (void (*)()) func, 2, arg1, arg2);
  </code></pre>
  
  <p>after I create the context like above, I use it and try to delete when I am done
  but I can't figure out how to delete uPtr->uc_stack.ss_sp.</p>
  
  <p>I tried</p>
  
  <pre><code>delete[] foo; //suppose I saved the char* stack in foo
  </code></pre>
  
  <p>but it gave me seg fault</p>
  
  <p>and when I tried</p>
  
  <pre><code>delete[] (char*)uPtr-&gt;uc_stack.sS_sp;
  </code></pre>
  
  <p>I don't think it properly deletes the stack.
  Does anyone know how to do this?
  Thank you very much</p>