================= idDeclLocal::SetTextLocal ================= */
| 1923 | ================= |
| 1924 | */ |
| 1925 | void idDeclLocal::SetTextLocal( const char *text, const int length ) { |
| 1926 | |
| 1927 | Mem_Free( textSource ); |
| 1928 | |
| 1929 | checksum = MD5_BlockChecksum( text, length ); |
| 1930 | |
| 1931 | #ifdef GET_HUFFMAN_FREQUENCIES |
| 1932 | for( int i = 0; i < length; i++ ) { |
| 1933 | huffmanFrequencies[((const unsigned char *)text)[i]]++; |
| 1934 | } |
| 1935 | #endif |
| 1936 | |
| 1937 | #ifdef USE_COMPRESSED_DECLS |
| 1938 | int maxBytesPerCode = ( maxHuffmanBits + 7 ) >> 3; |
| 1939 | byte *compressed = (byte *)_alloca( length * maxBytesPerCode ); |
| 1940 | compressedLength = HuffmanCompressText( text, length, compressed, length * maxBytesPerCode ); |
| 1941 | textSource = (char *)Mem_Alloc( compressedLength ); |
| 1942 | memcpy( textSource, compressed, compressedLength ); |
| 1943 | #else |
| 1944 | compressedLength = length; |
| 1945 | textSource = (char *) Mem_Alloc( length + 1 ); |
| 1946 | memcpy( textSource, text, length ); |
| 1947 | textSource[length] = '\0'; |
| 1948 | #endif |
| 1949 | textLength = length; |
| 1950 | } |
| 1951 | |
| 1952 | /* |
| 1953 | ================= |
no test coverage detected