MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / SetTextLocal

Method SetTextLocal

neo/framework/DeclManager.cpp:1925–1950  ·  view source on GitHub ↗

================= idDeclLocal::SetTextLocal ================= */

Source from the content-addressed store, hash-verified

1923=================
1924*/
1925void 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=================

Callers 2

LoadAndParseMethod · 0.80
CreateNewDeclMethod · 0.80

Calls 4

Mem_FreeFunction · 0.85
MD5_BlockChecksumFunction · 0.85
HuffmanCompressTextFunction · 0.85
Mem_AllocFunction · 0.85

Tested by

no test coverage detected