99 * modify it under the terms of the GNU Lesser General Public
1010 * License as published by the Free Software Foundation; either
1111 * version 2.1 of the License, or (at your option) any later version.
12- *
12+ *
1313 * This library is distributed in the hope that it will be useful,
1414 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1515 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1616 * Lesser General Public License for more details.
17- *
17+ *
1818 * You should have received a copy of the GNU Lesser General Public
1919 * License along with this library; if not, write to the Free Software
2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21- *
21+ *
2222 * $Id$
2323 *
2424 */
@@ -44,7 +44,7 @@ pylzma_compress(PyObject *self, PyObject *args, PyObject *kwargs)
4444 CMemoryInStream inStream ;
4545 Byte header [LZMA_PROPS_SIZE ];
4646 size_t headerSize = LZMA_PROPS_SIZE ;
47- int res ;
47+ int res ;
4848 // possible keywords for this function
4949 static char * kwlist [] = {"data" , "dictionary" , "fastBytes" , "literalContextBits" ,
5050 "literalPosBits" , "posBits" , "algorithm" , "eos" , "multithreading" , "matchfinder" , NULL };
@@ -58,37 +58,37 @@ pylzma_compress(PyObject *self, PyObject *args, PyObject *kwargs)
5858 char * matchfinder = NULL ; // matchfinder algorithm
5959 int algorithm = 2 ;
6060 char * data ;
61- PARSE_LENGTH_TYPE length ;
61+ Py_ssize_t length ;
6262
6363 if (!PyArg_ParseTupleAndKeywords (args , kwargs , "s#|iiiiiiiis" , kwlist , & data , & length , & dictionary , & fastBytes ,
6464 & literalContextBits , & literalPosBits , & posBits , & algorithm , & eos , & multithreading , & matchfinder ))
6565 return NULL ;
66-
66+
6767 outStream .data = NULL ;
6868 CHECK_RANGE (dictionary , 0 , 27 , "dictionary must be between 0 and 27" );
6969 CHECK_RANGE (fastBytes , 5 , 273 , "fastBytes must be between 5 and 273" );
7070 CHECK_RANGE (literalContextBits , 0 , 8 , "literalContextBits must be between 0 and 8" );
7171 CHECK_RANGE (literalPosBits , 0 , 4 , "literalPosBits must be between 0 and 4" );
7272 CHECK_RANGE (posBits , 0 , 4 , "posBits must be between 0 and 4" );
7373 CHECK_RANGE (algorithm , 0 , 2 , "algorithm must be between 0 and 2" );
74-
74+
7575 if (matchfinder != NULL ) {
7676#if (PY_VERSION_HEX >= 0x02050000 )
7777 PyErr_WarnEx (PyExc_DeprecationWarning , "matchfinder selection is deprecated and will be ignored" , 1 );
7878#else
7979 PyErr_Warn (PyExc_DeprecationWarning , "matchfinder selection is deprecated and will be ignored" );
8080#endif
8181 }
82-
82+
8383 encoder = LzmaEnc_Create (& allocator );
8484 if (encoder == NULL )
8585 return PyErr_NoMemory ();
86-
86+
8787 CreateMemoryInStream (& inStream , (Byte * ) data , length );
8888 CreateMemoryOutStream (& outStream );
89-
89+
9090 LzmaEncProps_Init (& props );
91-
91+
9292 props .dictSize = 1 << dictionary ;
9393 props .lc = literalContextBits ;
9494 props .lp = literalPosBits ;
@@ -119,16 +119,16 @@ pylzma_compress(PyObject *self, PyObject *args, PyObject *kwargs)
119119 PyErr_Format (PyExc_TypeError , "Error during compressing: %d" , res );
120120 goto exit ;
121121 }
122-
122+
123123 result = PyBytes_FromStringAndSize ((const char * ) outStream .data , outStream .size );
124-
124+
125125exit :
126126 if (encoder != NULL ) {
127127 LzmaEnc_Destroy (encoder , & allocator , & allocator );
128128 }
129129 if (outStream .data != NULL ) {
130130 free (outStream .data );
131131 }
132-
132+
133133 return result ;
134134}
0 commit comments