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 *)
67 for (i = 0; i < map->
rows; i++) {
98 for (i = 0; i < map->
rows; i++) {
133 struct BMlink *p, *p2, *prev;
143 if (cur_x + p->
count > x) {
157 dist_b = (cur_x + p->
count - 1) - x;
160 if (dist_b == 0 && p->
next && p->
next->
val == val) {
161 if (dist_a == 0 && x > 0) {
162 if (prev !=
NULL && prev->
val == val) {
173 if (dist_b == 0 && p->
next && p->
next->
val == val) {
189 if (dist_a == 0 && x > 0) {
191 if (prev !=
NULL && prev->
val == val) {
255 if (cur_x + p->
count > x)
280 size = (size_t) map->
rows *
sizeof(
struct BMlink *);
281 for (i = 0; i < map->
rows; i++) {
284 size +=
sizeof(
struct BMlink);
309 for (i = 0; i < map->
rows; i++) {
312 fprintf(stdout,
"(%2d %2d) ", p->
count, p->
val);
315 fprintf(stdout,
"\n");
343 fprintf(stdout,
"(%2d %2d) ", p->
count, p->
val);
346 fprintf(stdout,
"\n");
373 fwrite(&c,
sizeof(
char),
sizeof(
char), fp);
378 fwrite(&c,
sizeof(
char),
sizeof(
char), fp);
380 fwrite(&(map->
rows),
sizeof(map->
rows),
sizeof(
char), fp);
382 fwrite(&(map->
cols),
sizeof(map->
cols),
sizeof(
char), fp);
384 for (y = 0; y < map->
rows; y++) {
394 fwrite(&i,
sizeof(i),
sizeof(
char), fp);
401 fwrite(&i,
sizeof(i),
sizeof(
char), fp);
404 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'.