aboutsummaryrefslogtreecommitdiff
path: root/src/depmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/depmap.c')
-rw-r--r--src/depmap.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/depmap.c b/src/depmap.c
index cb50548..d2bf536 100644
--- a/src/depmap.c
+++ b/src/depmap.c
@@ -1,5 +1,5 @@
1/* This file is part of GNU Pies. 1/* This file is part of GNU Pies.
2 Copyright (C) 2008-2013, 2016-2017 Sergey Poznyakoff 2 Copyright (C) 2008-2019 Sergey Poznyakoff
3 3
4 GNU Pies is free software; you can redistribute it and/or modify 4 GNU Pies is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -50,14 +50,14 @@ TC (unsigned *R, int n)
50 { 50 {
51 ccol = cword; 51 ccol = cword;
52 rowj = R; 52 rowj = R;
53 53
54 while (rowj < relend) 54 while (rowj < relend)
55 { 55 {
56 if (*ccol & mask) 56 if (*ccol & mask)
57 { 57 {
58 rp = rowi; 58 rp = rowi;
59 rend = (unsigned *) ((char *) rowj + rowsize); 59 rend = (unsigned *) ((char *) rowj + rowsize);
60 60
61 while (rowj < rend) 61 while (rowj < rend)
62 *rowj++ |= *rp++; 62 *rowj++ |= *rp++;
63 } 63 }
@@ -65,10 +65,10 @@ TC (unsigned *R, int n)
65 { 65 {
66 rowj = (unsigned *) ((char *) rowj + rowsize); 66 rowj = (unsigned *) ((char *) rowj + rowsize);
67 } 67 }
68 68
69 ccol = (unsigned *) ((char *) ccol + rowsize); 69 ccol = (unsigned *) ((char *) ccol + rowsize);
70 } 70 }
71 71
72 mask <<= 1; 72 mask <<= 1;
73 if (mask == 0) 73 if (mask == 0)
74 { 74 {
@@ -85,12 +85,12 @@ struct pies_depmap
85 size_t rowlen; /* Length of a row in words */ 85 size_t rowlen; /* Length of a row in words */
86 unsigned r[1]; /* Data rows */ 86 unsigned r[1]; /* Data rows */
87}; 87};
88 88
89pies_depmap_t 89pies_depmap_t
90depmap_alloc (size_t count) 90depmap_alloc (size_t count)
91{ 91{
92 size_t size = (count + BITS_PER_WORD - 1) / BITS_PER_WORD; 92 size_t size = (count + BITS_PER_WORD - 1) / BITS_PER_WORD;
93 pies_depmap_t dmap = grecs_zalloc (sizeof (*dmap) - 1 93 pies_depmap_t dmap = grecs_zalloc (sizeof (*dmap) - 1
94 + count * size * sizeof (unsigned)); 94 + count * size * sizeof (unsigned));
95 dmap->nrows = count; 95 dmap->nrows = count;
96 dmap->rowlen = size; 96 dmap->rowlen = size;
@@ -102,7 +102,7 @@ static inline size_t
102depmap_row_size (pies_depmap_t dpm) 102depmap_row_size (pies_depmap_t dpm)
103{ 103{
104 return dpm->rowlen * sizeof (unsigned); 104 return dpm->rowlen * sizeof (unsigned);
105} 105}
106 106
107pies_depmap_t 107pies_depmap_t
108depmap_copy (pies_depmap_t dpm) 108depmap_copy (pies_depmap_t dpm)
@@ -158,9 +158,9 @@ depmap_next (pies_depmap_t dmap, pies_depmap_pos_t pos)
158 pos->coord[pos->dir]++) 158 pos->coord[pos->dir]++)
159 if (depmap_isset (dmap, pos->coord[0], pos->coord[1])) 159 if (depmap_isset (dmap, pos->coord[0], pos->coord[1]))
160 break; 160 break;
161 161
162 return pos->coord[pos->dir] == dmap->nrows ? 162 return pos->coord[pos->dir] == dmap->nrows ?
163 (size_t) -1 : pos->coord[pos->dir]; 163 (size_t) -1 : pos->coord[pos->dir];
164} 164}
165 165
166size_t 166size_t
@@ -188,7 +188,7 @@ depmap_remove (pies_depmap_t dmap, size_t n)
188 if (n < dmap->nrows - 1) 188 if (n < dmap->nrows - 1)
189 { 189 {
190 size_t i, j; 190 size_t i, j;
191 191
192 /* Remove nth row */ 192 /* Remove nth row */
193 memmove (depmap_rowptr (dmap, n), depmap_rowptr (dmap, n + 1), 193 memmove (depmap_rowptr (dmap, n), depmap_rowptr (dmap, n + 1),
194 (dmap->nrows - n - 1) * depmap_row_size (dmap)); 194 (dmap->nrows - n - 1) * depmap_row_size (dmap));

Return to:

Send suggestions and report system problems to the System administrator.