Lines Matching refs:buffer

155 static void allocate(size_t size, uint8_t** buffer, size_t* buffer_alloc) {  in allocate()  argument
159 free(*buffer); in allocate()
161 *buffer = (uint8_t*) malloc(size); in allocate()
162 if (*buffer == NULL) { in allocate()
292 static int ReadBlocks(RangeSet* src, uint8_t* buffer, int fd) { in ReadBlocks() argument
297 if (!src || !buffer) { in ReadBlocks()
308 if (read_all(fd, buffer + p, size) == -1) { in ReadBlocks()
318 static int WriteBlocks(RangeSet* tgt, uint8_t* buffer, int fd) { in WriteBlocks() argument
323 if (!tgt || !buffer) { in WriteBlocks()
334 if (write_all(fd, buffer + p, size) == -1) { in WriteBlocks()
355 uint8_t** buffer, size_t* buffer_alloc, int fd) { in LoadSrcTgtVersion1() argument
367 allocate(src->size * BLOCKSIZE, buffer, buffer_alloc); in LoadSrcTgtVersion1()
368 rc = ReadBlocks(src, *buffer, fd); in LoadSrcTgtVersion1()
375 static int VerifyBlocks(const char *expected, const uint8_t *buffer, in VerifyBlocks() argument
381 if (!expected || !buffer) { in VerifyBlocks()
385 SHA_hash(buffer, blocks * BLOCKSIZE, digest); in VerifyBlocks()
556 static int LoadStash(const char* base, const char* id, int verify, int* blocks, uint8_t** buffer, in LoadStash() argument
565 if (!base || !id || !buffer || !buffer_alloc) { in LoadStash()
602 allocate(st.st_size, buffer, buffer_alloc); in LoadStash()
604 if (read_all(fd, *buffer, st.st_size) == -1) { in LoadStash()
610 if (verify && VerifyBlocks(id, *buffer, *blocks, 1) != 0) { in LoadStash()
630 static int WriteStash(const char* base, const char* id, int blocks, uint8_t* buffer, in WriteStash() argument
640 if (base == NULL || buffer == NULL) { in WriteStash()
681 if (write_all(fd, buffer, blocks * BLOCKSIZE) == -1) { in WriteStash()
815 static int SaveStash(const char* base, char** wordsave, uint8_t** buffer, size_t* buffer_alloc, in SaveStash() argument
821 if (!wordsave || !buffer || !buffer_alloc || !isunresumable) { in SaveStash()
832 if (usehash && LoadStash(base, id, 1, &blocks, buffer, buffer_alloc, 0) == 0) { in SaveStash()
839 if (LoadSrcTgtVersion1(wordsave, NULL, &blocks, buffer, buffer_alloc, fd) == -1) { in SaveStash()
843 if (usehash && VerifyBlocks(id, *buffer, blocks, 1) != 0) { in SaveStash()
853 return WriteStash(base, id, blocks, *buffer, 0, NULL); in SaveStash()
909 uint8_t** buffer, size_t* buffer_alloc, int fd, in LoadSrcTgtVersion2() argument
928 allocate(*src_blocks * BLOCKSIZE, buffer, buffer_alloc); in LoadSrcTgtVersion2()
935 res = ReadBlocks(src, *buffer, fd); in LoadSrcTgtVersion2()
954 MoveRange(*buffer, locs, *buffer); in LoadSrcTgtVersion2()
977 MoveRange(*buffer, locs, stash); in LoadSrcTgtVersion2()
1004 uint8_t* buffer; member
1056 if (LoadSrcTgtVersion2(&params->cpos, tgt, src_blocks, &params->buffer, &params->bufsize, in LoadSrcTgtVersion3()
1078 if (VerifyBlocks(srchash, params->buffer, *src_blocks, 1) == 0) { in LoadSrcTgtVersion3()
1085 if (WriteStash(params->stashbase, srchash, *src_blocks, params->buffer, 1, in LoadSrcTgtVersion3()
1102 if (*overlap && LoadStash(params->stashbase, srchash, 1, NULL, &params->buffer, in LoadSrcTgtVersion3()
1135 status = LoadSrcTgtVersion1(&params->cpos, &tgt, &blocks, &params->buffer, in PerformCommandMove()
1138 status = LoadSrcTgtVersion2(&params->cpos, &tgt, &blocks, &params->buffer, in PerformCommandMove()
1159 if (WriteBlocks(tgt, params->buffer, params->fd) == -1) { in PerformCommandMove()
1189 return SaveStash(params->stashbase, &params->cpos, &params->buffer, &params->bufsize, in PerformCommandStash()
1227 allocate(BLOCKSIZE, &params->buffer, &params->bufsize); in PerformCommandZero()
1228 memset(params->buffer, 0, BLOCKSIZE); in PerformCommandZero()
1237 if (write_all(params->fd, params->buffer, BLOCKSIZE) == -1) { in PerformCommandZero()
1349 status = LoadSrcTgtVersion1(&params->cpos, &tgt, &blocks, &params->buffer, in PerformCommandDiff()
1352 status = LoadSrcTgtVersion2(&params->cpos, &tgt, &blocks, &params->buffer, in PerformCommandDiff()
1387 ApplyImagePatch(params->buffer, blocks * BLOCKSIZE, &patch_value, in PerformCommandDiff()
1390 ApplyBSDiffPatch(params->buffer, blocks * BLOCKSIZE, &patch_value, in PerformCommandDiff()
1765 if (params.buffer) { in PerformBlockImageUpdate()
1766 free(params.buffer); in PerformBlockImageUpdate()
1913 uint8_t buffer[BLOCKSIZE]; in RangeSha1Fn() local
1927 if (read_all(fd, buffer, BLOCKSIZE) == -1) { in RangeSha1Fn()
1933 SHA_update(&ctx, buffer, BLOCKSIZE); in RangeSha1Fn()