On Fri, Aug 18, 2017 at 10:39:29AM +0300, Konstantin Khomoutov wrote:

[...]
> There can't be easy answer to a question like this in C.
> Consider:
> 
>   // This function clearly transfers the ownership of the memory
>   // it returns to the caller.
>   int* allocate(int n)
>   {
>     int *mem = (int*)malloc(n * sizeof(int));
>     if (mem == NULL) {
>       panic("Out of memory");
>     }
>   }

Sorry, I've missed the crucial return statement; the code should have
instead been:

   // This function clearly transfers the ownership of the memory
   // it returns to the caller.
   int* allocate(int n)
   {
     int *mem = (int*)malloc(n * sizeof(int));
     if (mem == NULL) {
       panic("Out of memory");
     }
     return mem;
   }

[...]

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to