Lines Matching refs:pchk
42 { const READ_CHUNKS * pchk = &psf->rchunks ; in psf_get_chunk_iterator() local
46 idx = psf_find_read_chunk_str (pchk, marker_str) ; in psf_get_chunk_iterator()
48 idx = pchk->used > 0 ? 0 : -1 ; in psf_get_chunk_iterator()
88 psf_next_chunk_iterator (const READ_CHUNKS * pchk , SF_CHUNK_ITERATOR * iterator) in psf_next_chunk_iterator() argument
95 { for (k = iterator->current ; k < pchk->used ; k++) in psf_next_chunk_iterator()
96 if (pchk->chunks [k].hash == hash) in psf_next_chunk_iterator()
101 else if (iterator->current < pchk->used) in psf_next_chunk_iterator()
110 psf_store_read_chunk (READ_CHUNKS * pchk, const READ_CHUNK * rchunk) in psf_store_read_chunk() argument
111 { if (pchk->count == 0) in psf_store_read_chunk()
112 { pchk->used = 0 ; in psf_store_read_chunk()
113 pchk->count = 20 ; in psf_store_read_chunk()
114 pchk->chunks = calloc (pchk->count, sizeof (READ_CHUNK)) ; in psf_store_read_chunk()
116 else if (pchk->used > pchk->count) in psf_store_read_chunk()
118 else if (pchk->used == pchk->count) in psf_store_read_chunk()
119 { READ_CHUNK * old_ptr = pchk->chunks ; in psf_store_read_chunk()
120 int new_count = 3 * (pchk->count + 1) / 2 ; in psf_store_read_chunk()
122 pchk->chunks = realloc (old_ptr, new_count * sizeof (READ_CHUNK)) ; in psf_store_read_chunk()
123 if (pchk->chunks == NULL) in psf_store_read_chunk()
124 { pchk->chunks = old_ptr ; in psf_store_read_chunk()
127 pchk->count = new_count ; in psf_store_read_chunk()
130 pchk->chunks [pchk->used] = *rchunk ; in psf_store_read_chunk()
132 pchk->used ++ ; in psf_store_read_chunk()
138 psf_store_read_chunk_u32 (READ_CHUNKS * pchk, uint32_t marker, sf_count_t offset, uint32_t len) in psf_store_read_chunk_u32() argument
151 return psf_store_read_chunk (pchk, &rchunk) ; in psf_store_read_chunk_u32()
155 psf_find_read_chunk_str (const READ_CHUNKS * pchk, const char * marker_str) in psf_find_read_chunk_str() argument
167 for (k = 0 ; k < pchk->used ; k++) in psf_find_read_chunk_str()
168 if (pchk->chunks [k].hash == hash) in psf_find_read_chunk_str()
175 psf_find_read_chunk_m32 (const READ_CHUNKS * pchk, uint32_t marker) in psf_find_read_chunk_m32() argument
178 for (k = 0 ; k < pchk->used ; k++) in psf_find_read_chunk_m32()
179 if (pchk->chunks [k].mark32 == marker) in psf_find_read_chunk_m32()
185 psf_find_read_chunk_iterator (const READ_CHUNKS * pchk, const SF_CHUNK_ITERATOR * marker) in psf_find_read_chunk_iterator() argument
186 { if (marker->current < pchk->used) in psf_find_read_chunk_iterator()
193 psf_store_read_chunk_str (READ_CHUNKS * pchk, const char * marker_str, sf_count_t offset, uint32_t … in psf_store_read_chunk_str() argument
214 return psf_store_read_chunk (pchk, &rchunk) ; in psf_store_read_chunk_str()
218 psf_save_write_chunk (WRITE_CHUNKS * pchk, const SF_CHUNK_INFO * chunk_info) in psf_save_write_chunk() argument
226 if (pchk->count == 0) in psf_save_write_chunk()
227 { pchk->used = 0 ; in psf_save_write_chunk()
228 pchk->count = 20 ; in psf_save_write_chunk()
229 pchk->chunks = calloc (pchk->count, sizeof (WRITE_CHUNK)) ; in psf_save_write_chunk()
231 else if (pchk->used >= pchk->count) in psf_save_write_chunk()
232 { WRITE_CHUNK * old_ptr = pchk->chunks ; in psf_save_write_chunk()
233 int new_count = 3 * (pchk->count + 1) / 2 ; in psf_save_write_chunk()
235 pchk->chunks = realloc (old_ptr, new_count * sizeof (WRITE_CHUNK)) ; in psf_save_write_chunk()
236 if (pchk->chunks == NULL) in psf_save_write_chunk()
237 { pchk->chunks = old_ptr ; in psf_save_write_chunk()
247 …pchk->chunks [pchk->used].hash = strlen (chunk_info->id) > 4 ? hash_of_str (chunk_info->id) : u.ma… in psf_save_write_chunk()
248 pchk->chunks [pchk->used].mark32 = u.marker ; in psf_save_write_chunk()
249 pchk->chunks [pchk->used].len = len ; in psf_save_write_chunk()
250 pchk->chunks [pchk->used].data = psf_memdup (chunk_info->data, chunk_info->datalen) ; in psf_save_write_chunk()
252 pchk->used ++ ; in psf_save_write_chunk()