26 #define BM_col_to_byte(x) ((x) >> 3) 27 #define BM_col_to_bit(x) ((x) & 7) 51 map->
bytes = (x + 7) / 8;
53 if (
NULL == (map->
data = (
unsigned char *)
64 for (i = 0; i < map->
rows; i++) {
95 for (i = 0; i < map->
rows; i++) {
130 struct BMlink *p, *p2, *prev;
140 if (cur_x + p->
count > x) {
155 dist_b = (cur_x + p->
count - 1) - x;
158 if (dist_b == 0 && p->
next && p->
next->
val == val) {
159 if (dist_a == 0 && x > 0) {
160 if (prev !=
NULL && prev->
val == val) {
171 if (dist_b == 0 && p->
next && p->
next->
val == val) {
187 if (dist_a == 0 && x > 0) {
189 if (prev !=
NULL && prev->
val == val) {
253 if (cur_x + p->
count > x)
278 size = (size_t) map->
rows *
sizeof(
struct BMlink *);
279 for (i = 0; i < map->
rows; i++) {
282 size +=
sizeof(
struct BMlink);
307 for (i = 0; i < map->
rows; i++) {
310 fprintf(stdout,
"(%2d %2d) ", p->
count, p->
val);
313 fprintf(stdout,
"\n");
341 fprintf(stdout,
"(%2d %2d) ", p->
count, p->
val);
344 fprintf(stdout,
"\n");
372 fwrite(&c,
sizeof(
char),
sizeof(
char), fp);
377 fwrite(&c,
sizeof(
char),
sizeof(
char), fp);
379 fwrite(&(map->
rows),
sizeof(map->
rows),
sizeof(
char), fp);
381 fwrite(&(map->
cols),
sizeof(map->
cols),
sizeof(
char), fp);
383 for (y = 0; y < map->
rows; y++) {
393 fwrite(&i,
sizeof(i),
sizeof(
char), fp);
400 fwrite(&i,
sizeof(i),
sizeof(
char), fp);
403 fwrite(&i,
sizeof(i),
sizeof(
char), fp);
void link_set_chunk_size(int)
void link_dispose(struct link_head *, VOID_T *)
void link_cleanup(struct link_head *)
VOID_T * link_new(struct link_head *)
struct BM * BM_create_sparse(int x, int y)
Create a sparse bitmap of dimension 'x'/'y'.
size_t BM_get_map_size_sparse(struct BM *map)
Returns size of sparse bitmap in bytes.
int BM_dump_map_row_sparse(struct BM *map, int y)
Debugging code to dump out structure of links for single row.
struct link_head * link_init(int)
int BM_file_write_sparse(FILE *fp, struct BM *map)
Write sparse bitmap matrix out to disk file 'fp'. NOTE: 'fp' must already be opened and later closed ...
int BM_get_sparse(struct BM *map, int x, int y)
Returns sparse bitmap value at location 'x'/'y'.
int BM_destroy_sparse(struct BM *map)
Destroy sparse bitmap and free all associated memory.
int BM_dump_map_sparse(struct BM *map)
Debugging code to dump out structure of links.
int BM_set_sparse(struct BM *map, int x, int y, int val)
Set sparse bitmap value to 'val' at location 'x'/'y'.