Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #7807

Re: Array implementation of Stack

From "io_x" <a@b.c.invalid>
Newsgroups comp.lang.c
References <4df9d41f$0$308$14726298@news.sunsite.dk> <4dfceef1$0$44207$4fafbaef@reader1.news.tin.it> <4e058797$0$44207$4fafbaef@reader1.news.tin.it> <4e06c256$0$15665$4fafbaef@reader2.news.tin.it>
Subject Re: Array implementation of Stack
Date 2011-07-07 06:59 +0200
Message-ID <4e153ccf$0$15663$4fafbaef@reader2.news.tin.it> (permalink)
Organization TIN.IT (http://www.tin.it)

Show all headers | View raw


"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4e06c256$0$15665$4fafbaef@reader2.news.tin.it...
>
> u32  IniStack(stack**  v, u32  sz)
> {u32       t;
> stack   *vv;
> sele   *arr;
>
> if(sz==0||v==0||sz>0xFFFFFF)
>                      R  -1;
> vv = malloc(S(stack));
> if(vv==0)            R  -1;
> t=sz; t*=S(sele);
> if(t<sz ||t==0||t > 0xFFFFFF)
>     {err: free(vv); *v=0; R  -1;}
> arr=malloc(t); if(t==0) G err;
> *v=vv; vv->top=-1; vv->size=sz;
> vv->arr=arr;  vv->notUsed=0;
> R  0;
> }

the below is one much better language

<< top=0,  size=4,  arr=8, notUsed=12

;0k,4j,8i,12ra, 16P_v, 20P_sz
IniStack:
<i,j,k
    i=^16  |j=^20
    i==0#.e|j<=0?#.e|D*i=0|#.1
.e: a=-1|stc|#.z
.1: malloc<(16)|a==0#.e|k=a
    a=j|c=8    |mul   c|r#.2
    malloc<(a) |a==0!#.3
.2:    free<(k)|#.e
.3: *i=k
    D*k+top=-1|D*k+size   =j
    D*k+arr= a|D*k+notUsed=0
    a^=a  ; => CF==0
.z:
>i,j,k
ret  8
etc etc

>> top,  size,  arr, notUsed




Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Array implementation of Stack "io_x" <a@b.c.invalid> - 2011-06-18 20:32 +0200
  Re: Array implementation of Stack "io_x" <a@b.c.invalid> - 2011-06-25 09:02 +0200
    Re: Array implementation of Stack "io_x" <a@b.c.invalid> - 2011-06-26 07:25 +0200
      Re: Array implementation of Stack pete <pfiland@mindspring.com> - 2011-06-26 02:11 -0400
        Re: Array implementation of Stack "io_x" <a@b.c.invalid> - 2011-06-26 19:08 +0200
      Re: Array implementation of Stack "io_x" <a@b.c.invalid> - 2011-07-07 06:59 +0200
        Re: Array implementation of Stack Shao Miller <sha0.miller@gmail.com> - 2011-07-07 19:25 -0400
          Re: Array implementation of Stack "io_x" <a@b.c.invalid> - 2011-07-08 20:06 +0200
  Re: Array implementation of Stack "io_x" <a@b.c.invalid> - 2011-06-25 11:29 +0200
    Re: Array implementation of Stack "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-25 03:04 -0700
      Re: Array implementation of Stack Ian Collins <ian-news@hotmail.com> - 2011-06-25 22:23 +1200
      Re: Array implementation of Stack Patrick Scheible <kkt@zipcon.net> - 2011-06-25 16:29 -0700

csiph-web