The R Project SVN R

Rev

Rev 53508 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 53508 Rev 55994
Line 49... Line 49...
49
	if (filters == NULL || (unsigned int)(check) > LZMA_CHECK_ID_MAX
49
	if (filters == NULL || (unsigned int)(check) > LZMA_CHECK_ID_MAX
50
			|| (in == NULL && in_size != 0) || out == NULL
50
			|| (in == NULL && in_size != 0) || out == NULL
51
			|| out_pos_ptr == NULL || *out_pos_ptr > out_size)
51
			|| out_pos_ptr == NULL || *out_pos_ptr > out_size)
52
		return LZMA_PROG_ERROR;
52
		return LZMA_PROG_ERROR;
53
 
53
 
-
 
54
	if (!lzma_check_is_supported(check))
-
 
55
		return LZMA_UNSUPPORTED_CHECK;
-
 
56
 
54
	// Note for the paranoids: Index encoder prevents the Stream from
57
	// Note for the paranoids: Index encoder prevents the Stream from
55
	// getting too big and still being accepted with LZMA_OK, and Block
58
	// getting too big and still being accepted with LZMA_OK, and Block
56
	// encoder catches if the input is too big. So we don't need to
59
	// encoder catches if the input is too big. So we don't need to
57
	// separately check if the buffers are too big.
60
	// separately check if the buffers are too big.
58
 
61
 
Line 79... Line 82...
79
			!= LZMA_OK)
82
			!= LZMA_OK)
80
		return LZMA_PROG_ERROR;
83
		return LZMA_PROG_ERROR;
81
 
84
 
82
	out_pos += LZMA_STREAM_HEADER_SIZE;
85
	out_pos += LZMA_STREAM_HEADER_SIZE;
83
 
86
 
84
	// Block
87
	// Encode a Block but only if there is at least one byte of input.
85
	lzma_block block = {
88
	lzma_block block = {
86
		.version = 0,
89
		.version = 0,
87
		.check = check,
90
		.check = check,
88
		.filters = filters,
91
		.filters = filters,
89
	};
92
	};
90
 
93
 
-
 
94
	if (in_size > 0)
91
	return_if_error(lzma_block_buffer_encode(&block, allocator,
95
		return_if_error(lzma_block_buffer_encode(&block, allocator,
92
			in, in_size, out, &out_pos, out_size));
96
				in, in_size, out, &out_pos, out_size));
93
 
97
 
94
	// Index
98
	// Index
95
	{
99
	{
96
		// Create an Index with one Record.
100
		// Create an Index. It will have one Record if there was
-
 
101
		// at least one byte of input to encode. Otherwise the
-
 
102
		// Index will be empty.
97
		lzma_index *i = lzma_index_init(allocator);
103
		lzma_index *i = lzma_index_init(allocator);
98
		if (i == NULL)
104
		if (i == NULL)
99
			return LZMA_MEM_ERROR;
105
			return LZMA_MEM_ERROR;
100
 
106
 
-
 
107
		lzma_ret ret = LZMA_OK;
-
 
108
 
-
 
109
		if (in_size > 0)
101
		lzma_ret ret = lzma_index_append(i, allocator,
110
			ret = lzma_index_append(i, allocator,
102
				lzma_block_unpadded_size(&block),
111
					lzma_block_unpadded_size(&block),
103
				block.uncompressed_size);
112
					block.uncompressed_size);
104
 
113
 
105
		// If adding the Record was successful, encode the Index
114
		// If adding the Record was successful, encode the Index
106
		// and get its size which will be stored into Stream Footer.
115
		// and get its size which will be stored into Stream Footer.
107
		if (ret == LZMA_OK) {
116
		if (ret == LZMA_OK) {
108
			ret = lzma_index_buffer_encode(
117
			ret = lzma_index_buffer_encode(