Lines Matching refs:pchk
42 { const READ_CHUNKS * pchk = &psf->rchunks ;
46 idx = psf_find_read_chunk_str (pchk, marker_str) ;
48 idx = pchk->used > 0 ? 0 : -1 ;
88 psf_next_chunk_iterator (const READ_CHUNKS * pchk , SF_CHUNK_ITERATOR * iterator)
95 { for (k = iterator->current ; k < pchk->used ; k++)
96 if (pchk->chunks [k].hash == hash)
101 else if (iterator->current < pchk->used)
110 psf_store_read_chunk (READ_CHUNKS * pchk, const READ_CHUNK * rchunk)
111 { if (pchk->count == 0)
112 { pchk->used = 0 ;
113 pchk->count = 20 ;
114 pchk->chunks = calloc (pchk->count, sizeof (READ_CHUNK)) ;
115 if (!pchk->chunks)
119 else if (pchk->used > pchk->count)
121 else if (pchk->used == pchk->count)
122 { READ_CHUNK * old_ptr = pchk->chunks ;
123 int new_count = 3 * (pchk->count + 1) / 2 ;
125 pchk->chunks = realloc (old_ptr, new_count * sizeof (READ_CHUNK)) ;
126 if (pchk->chunks == NULL)
127 { pchk->chunks = old_ptr ;
130 pchk->count = new_count ;
133 pchk->chunks [pchk->used] = *rchunk ;
135 pchk->used ++ ;
141 psf_store_read_chunk_u32 (READ_CHUNKS * pchk, uint32_t marker, sf_count_t offset, uint32_t len)
154 return psf_store_read_chunk (pchk, &rchunk) ;
158 psf_find_read_chunk_str (const READ_CHUNKS * pchk, const char * marker_str)
170 for (k = 0 ; k < pchk->used ; k++)
171 if (pchk->chunks [k].hash == hash)
178 psf_find_read_chunk_m32 (const READ_CHUNKS * pchk, uint32_t marker)
181 for (k = 0 ; k < pchk->used ; k++)
182 if (pchk->chunks [k].mark32 == marker)
188 psf_find_read_chunk_iterator (const READ_CHUNKS * pchk, const SF_CHUNK_ITERATOR * marker)
189 { if (marker->current < pchk->used)
196 psf_store_read_chunk_str (READ_CHUNKS * pchk, const char * marker_str, sf_count_t offset, uint32_t len)
217 return psf_store_read_chunk (pchk, &rchunk) ;
221 psf_save_write_chunk (WRITE_CHUNKS * pchk, const SF_CHUNK_INFO * chunk_info)
229 if (pchk->count == 0)
230 { pchk->used = 0 ;
231 pchk->count = 20 ;
232 pchk->chunks = calloc (pchk->count, sizeof (WRITE_CHUNK)) ;
233 if (!pchk->chunks)
237 else if (pchk->used >= pchk->count)
238 { WRITE_CHUNK * old_ptr = pchk->chunks ;
239 int new_count = 3 * (pchk->count + 1) / 2 ;
241 pchk->chunks = realloc (old_ptr, new_count * sizeof (WRITE_CHUNK)) ;
242 if (pchk->chunks == NULL)
243 { pchk->chunks = old_ptr ;
253 pchk->chunks [pchk->used].hash = strlen (chunk_info->id) > 4 ? hash_of_str (chunk_info->id) : u.marker ;
254 pchk->chunks [pchk->used].mark32 = u.marker ;
255 pchk->chunks [pchk->used].len = len ;
256 pchk->chunks [pchk->used].data = psf_memdup (chunk_info->data, chunk_info->datalen) ;
258 pchk->used ++ ;