32
32
cdef extern from *:
33
33
ctypedef unsigned long size_t
35
void * realloc(void *, size_t)
37
void memcpy(void *, void *, size_t)
34
void * malloc(size_t) nogil
35
void * realloc(void *, size_t) nogil
36
void free(void *) nogil
37
void memcpy(void *, void *, size_t) nogil
40
40
cdef extern from "delta.h":
338
339
result = PyString_FromStringAndSize(NULL, size)
339
340
dst_buf = <unsigned char*>PyString_AS_STRING(result)
347
data = _decode_copy_instruction(data, cmd, &cp_off, &cp_size)
348
if (cp_off + cp_size < cp_size or
349
cp_off + cp_size > source_size or
351
raise RuntimeError('Something wrong with:'
352
' cp_off = %s, cp_size = %s'
353
' source_size = %s, size = %s'
354
% (cp_off, cp_size, source_size, size))
355
memcpy(out, source + cp_off, cp_size)
357
size = size - cp_size
361
# cmd == 0 is reserved for future encoding
362
# extensions. In the mean time we must fail when
363
# encountering them (might be data corruption).
364
raise RuntimeError('Got delta opcode: 0, not supported')
366
raise RuntimeError('Insert instruction longer than remaining'
367
' bytes: %d > %d' % (cmd, size))
368
memcpy(out, data, cmd)
350
data = _decode_copy_instruction(data, cmd, &cp_off, &cp_size)
351
if (cp_off + cp_size < cp_size or
352
cp_off + cp_size > source_size or
356
memcpy(out, source + cp_off, cp_size)
358
size = size - cp_size
362
# cmd == 0 is reserved for future encoding
363
# extensions. In the mean time we must fail when
364
# encountering them (might be data corruption).
370
memcpy(out, data, cmd)
376
raise ValueError('Something wrong with:'
377
' cp_off = %s, cp_size = %s'
378
' source_size = %s, size = %s'
379
% (cp_off, cp_size, source_size, size))
381
raise ValueError('Got delta opcode: 0, not supported')
383
raise ValueError('Insert instruction longer than remaining'
384
' bytes: %d > %d' % (cmd, size))
374
387
if (data != top or size != 0):