/[pspp]/pspp/src/tab.c
ViewVC logotype

Diff of /pspp/src/tab.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by blp, Sun Jul 31 21:42:46 2005 UTC revision 1.25 by blp, Sat Oct 29 05:50:06 2005 UTC
# Line 47  struct som_table_class tab_table_class; Line 47  struct som_table_class tab_table_class;
47  struct tab_table *  struct tab_table *
48  tab_create (int nc, int nr, int reallocable)  tab_create (int nc, int nr, int reallocable)
49  {  {
50    void *(*alloc_func) (struct pool *, size_t);    void *(*alloc_func) (struct pool *, size_t n);
51      void *(*nalloc_func) (struct pool *, size_t n, size_t s);
52    
53    struct tab_table *t;    struct tab_table *t;
54        
# Line 65  tab_create (int nc, int nr, int realloca Line 66  tab_create (int nc, int nr, int realloca
66    t->nc = t->cf = nc;    t->nc = t->cf = nc;
67    t->l = t->r = t->t = t->b = 0;    t->l = t->r = t->t = t->b = 0;
68    
69      nalloc_func = reallocable ? pool_nmalloc : pool_nalloc;
70    alloc_func = reallocable ? pool_malloc : pool_alloc;    alloc_func = reallocable ? pool_malloc : pool_alloc;
71  #if GLOBAL_DEBUGGING  #if GLOBAL_DEBUGGING
72    t->reallocable = reallocable;    t->reallocable = reallocable;
73  #endif  #endif
74    
75    t->cc = alloc_func (t->container, nr * nc * sizeof *t->cc);    t->cc = nalloc_func (t->container, nr * nc, sizeof *t->cc);
76    t->ct = alloc_func (t->container, nr * nc);    t->ct = alloc_func (t->container, nr * nc);
77    memset (t->ct, TAB_EMPTY, nc * nr);    memset (t->ct, TAB_EMPTY, nc * nr);
78    
79    t->rh = alloc_func (t->container, nc * (nr + 1));    t->rh = nalloc_func (t->container, nc, nr + 1);
80    memset (t->rh, 0, nc * (nr + 1));    memset (t->rh, 0, nc * (nr + 1));
81    
82    t->hrh = alloc_func (t->container, sizeof *t->hrh * (nr + 1));    t->hrh = nalloc_func (t->container, nr + 1, sizeof *t->hrh);
83    memset (t->hrh, 0, sizeof *t->hrh * (nr + 1));    memset (t->hrh, 0, sizeof *t->hrh * (nr + 1));
84    
85    t->trh = alloc_func (t->container, nr + 1);    t->trh = alloc_func (t->container, nr + 1);
86    memset (t->trh, 0, nr + 1);    memset (t->trh, 0, nr + 1);
87    
88    t->rv = alloc_func (t->container, (nc + 1) * nr);    t->rv = nalloc_func (t->container, nr, nc + 1);
89    memset (t->rv, 0, (nc + 1) * nr);    memset (t->rv, 0, (nc + 1) * nr);
90    
91    t->wrv = alloc_func (t->container, sizeof *t->wrv * (nc + 1));    t->wrv = nalloc_func (t->container, nc + 1, sizeof *t->wrv);
92    memset (t->wrv, 0, sizeof *t->wrv * (nc + 1));    memset (t->wrv, 0, sizeof *t->wrv * (nc + 1));
93    
94    t->trv = alloc_func (t->container, nc + 1);    t->trv = alloc_func (t->container, nc + 1);
# Line 163  tab_realloc (struct tab_table *t, int nc Line 165  tab_realloc (struct tab_table *t, int nc
165        unsigned char *new_ct;        unsigned char *new_ct;
166        int r;        int r;
167    
168        new_cc = pool_malloc (t->container, nr * nc * sizeof *new_cc);        new_cc = pool_nmalloc (t->container, nr * nc, sizeof *new_cc);
169        new_ct = pool_malloc (t->container, nr * nc);        new_ct = pool_malloc (t->container, nr * nc);
170        for (r = 0; r < mr1; r++)        for (r = 0; r < mr1; r++)
171          {          {
# Line 179  tab_realloc (struct tab_table *t, int nc Line 181  tab_realloc (struct tab_table *t, int nc
181      }      }
182    else if (nr != t->nr)    else if (nr != t->nr)
183      {      {
184        t->cc = pool_realloc (t->container, t->cc, nr * nc * sizeof *t->cc);        t->cc = pool_nrealloc (t->container, t->cc, nr * nc, sizeof *t->cc);
185        t->ct = pool_realloc (t->container, t->ct, nr * nc);        t->ct = pool_realloc (t->container, t->ct, nr * nc);
186    
187        t->rh = pool_realloc (t->container, t->rh, nc * (nr + 1));        t->rh = pool_nrealloc (t->container, t->rh, nc, nr + 1);
188        t->rv = pool_realloc (t->container, t->rv, (nc + 1) * nr);        t->rv = pool_nrealloc (t->container, t->rv, nr, nc + 1);
189        t->trh = pool_realloc (t->container, t->trh, nr + 1);        t->trh = pool_realloc (t->container, t->trh, nr + 1);
190        t->hrh = pool_realloc (t->container, t->hrh,        t->hrh = pool_nrealloc (t->container, t->hrh, nr + 1, sizeof *t->hrh);
                              sizeof *t->hrh * (nr + 1));  
191                
192        if (nr > t->nr)        if (nr > t->nr)
193          {          {
# Line 938  tabi_table (struct som_entity *table) Line 939  tabi_table (struct som_entity *table)
939    tab_offset (t, 0, 0);    tab_offset (t, 0, 0);
940        
941    assert (t->w == NULL && t->h == NULL);    assert (t->w == NULL && t->h == NULL);
942    t->w = pool_alloc (t->container, sizeof *t->w * t->nc);    t->w = pool_nalloc (t->container, t->nc, sizeof *t->w);
943    t->h = pool_alloc (t->container, sizeof *t->h * t->nr);    t->h = pool_nalloc (t->container, t->nr, sizeof *t->h);
944  }  }
945    
946  /* Set the current output device to DRIVER. */  /* Set the current output device to DRIVER. */

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26