Sorry for late reply, thanks very much! I will have a try.
在 2017年8月18日星期五 UTC+8下午4:23:07,Konstantin Khomoutov写道:
>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.