Revision df7b954b som/ChunkIDSet/chunkids_encoding.c
som/ChunkIDSet/chunkids_encoding.c | ||
---|---|---|
36 | 36 |
{ |
37 | 37 |
int i; |
38 | 38 |
uint8_t *meta_p; |
39 |
uint32_t type = h ? h->type : -1; |
|
39 | 40 |
|
40 |
int_cpy(buff + 4, h->type);
|
|
41 |
int_cpy(buff + 4, type); |
|
41 | 42 |
int_cpy(buff + 8, meta_len); |
42 | 43 |
|
43 |
switch (h->type) {
|
|
44 |
switch (type) { |
|
44 | 45 |
case CIST_BITMAP: |
45 | 46 |
{ |
46 | 47 |
int elements; |
... | ... | |
77 | 78 |
meta_p = buff + 12 + h->n_elements * 4; |
78 | 79 |
|
79 | 80 |
break; |
81 |
case -1: |
|
82 |
int_cpy(buff, 0); |
|
83 |
meta_p = buff + 12; |
|
84 |
break; |
|
80 | 85 |
default: |
81 |
fprintf(stderr, "Invalid ChunkID encoding type %d\n", h->type);
|
|
86 |
fprintf(stderr, "Invalid ChunkID encoding type %d\n", type); |
|
82 | 87 |
|
83 | 88 |
return -1; |
84 | 89 |
} |
... | ... | |
94 | 99 |
{ |
95 | 100 |
int i; |
96 | 101 |
uint32_t size; |
97 |
uint8_t type;
|
|
102 |
uint32_t type;
|
|
98 | 103 |
struct chunkID_set *h; |
99 | 104 |
char cfg[32]; |
100 | 105 |
const uint8_t *meta_p; |
... | ... | |
103 | 108 |
type = int_rcpy(buff + 4); |
104 | 109 |
*meta_len = int_rcpy(buff + 8); |
105 | 110 |
|
106 |
sprintf(cfg, "size=%d,type=%d", size, type); |
|
107 |
h = chunkID_set_init(cfg); |
|
108 |
if (h == NULL) { |
|
109 |
fprintf(stderr, "Error in decoding chunkid set - not enough memory to create a chunkID set.\n"); |
|
110 |
return NULL; |
|
111 |
if (type != -1) { |
|
112 |
sprintf(cfg, "size=%d,type=%d", size, type); |
|
113 |
h = chunkID_set_init(cfg); |
|
114 |
if (h == NULL) { |
|
115 |
fprintf(stderr, "Error in decoding chunkid set - not enough memory to create a chunkID set.\n"); |
|
116 |
return NULL; |
|
117 |
} |
|
118 |
} else { |
|
119 |
h = NULL; |
|
111 | 120 |
} |
112 | 121 |
|
113 |
switch (h->type) {
|
|
122 |
switch (type) { |
|
114 | 123 |
case CIST_BITMAP: |
115 | 124 |
{ |
116 | 125 |
// uint8_t bitmap; |
... | ... | |
143 | 152 |
h->n_elements = size; |
144 | 153 |
meta_p = buff + 12 + size * 4; |
145 | 154 |
break; |
155 |
case -1: |
|
156 |
meta_p = buff + 12; |
|
157 |
break; |
|
146 | 158 |
default: |
147 | 159 |
fprintf(stderr, "Error in decoding chunkid set - wrong val.\n"); |
148 | 160 |
chunkID_set_free(h); |
Also available in: Unified diff