Debian Codegraph @

src/base/3graymap.c

raw
1 /*
2 * 3graymap.c - very simple 2d array handling
3 */
4
5 #include "mdjvucfg.h"
6 #include <minidjvu/minidjvu.h>
7 #include <stdlib.h>
8
9 MDJVU_IMPLEMENT unsigned char **mdjvu_create_2d_array(int32 w, int32 h)
10 {
11 int32 i;
12 unsigned char *data, **result;
13 result = (unsigned char **) calloc(h, sizeof(unsigned char *) + w);
14 data = (unsigned char *) (result + h);
15
16 for (i = 0; i < h; i++)
17 {
18 result[i] = data + w * i;
19 }
20
21 return result;
22 }
23
24 MDJVU_IMPLEMENT void mdjvu_destroy_2d_array(unsigned char **p)
25 {
26 free(p);
27 }