Various fixes:
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Mon, 13 Feb 2012 15:12:43 +0000 (15:12 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Mon, 13 Feb 2012 15:12:43 +0000 (15:12 +0000)
* rename symbols that conflict with libbp (enclose, bits, ...)
* allow to build as a standalone library, libTextCollection.a
* some fixes to cope with gcc/g++ 4.6 new deprecation list

git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/branches/TextCollection/library-split@1206 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

13 files changed:
HeapProfiler.cpp
lzindex/lztrie.c
lzindex/parentheses.c
lzindex/parentheses.h
makefile
swcsa/Makefile
swcsa/buildFacade.c
swcsa/intIndex/Makefile
swcsa/intIndex/icsa.h
swcsa/intIndex/psiGonzalo.c
swcsa/intIndex/psiHuffmanRLE.c
swcsa/utils/basics.c
swcsa/utils/basics.h

index 348fee6..7091a53 100644 (file)
@@ -27,7 +27,7 @@ unsigned long HeapProfiler::consumption = 0, HeapProfiler::maxConsumption = 0;
 AllocatedBlocks HeapProfiler::blocks;
 
 // Override initialising hook from the C library.
-void (*__malloc_initialize_hook) (void) = HeapProfiler::InitHooks;
+void (* volatile __malloc_initialize_hook) (void) = HeapProfiler::InitHooks;
 
 // Variables to save original hooks.
 void *(*HeapProfiler::old_malloc_hook)(size_t, const void *);
index 7e4453d..2ac090a 100644 (file)
@@ -174,7 +174,7 @@ trieNode parentLZTrie (lztrie T, trieNode i)
  { 
     if (i == ROOT) return NULLT; // parent of root
     if (T->boost[T->letters[i-rank(T->pdata->bdata,i)]] == i) return ROOT;
-    return enclose (T->pdata,i);
+    return _enclose (T->pdata,i);
  }
 
        // subtree size
index 15c8a92..abb0a17 100644 (file)
@@ -275,7 +275,7 @@ uint excess (parentheses P, uint i)
         // open position of closest parentheses pair that contains the pair
         // that opens at i, ~0 if no parent
 
-uint enclose (parentheses P, uint i)
+uint _enclose (parentheses P, uint i)
 
    { if (i == 0) return ~0; // no parent!
      return findparent (P,i);
index 05b6aaa..b1a821a 100644 (file)
@@ -35,7 +35,7 @@ uint findopen (parentheses P, uint i);
 uint excess (parentheses P, uint i);
        // open position of closest parentheses pair that contains the pair
        // that opens at i, ~0 if no parent
-uint enclose (parentheses P, uint i);
+uint _enclose (parentheses P, uint i);
 
 uint sizeofParentheses(parentheses P);
 #endif
index 8c88467..92d83d8 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,24 +1,28 @@
+HIDE=@
 CC = g++
 LIBCDSPATH = ../libcds
-CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ -O3 -DNDEBUG
+CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ -O3 -DNDEBUG -Wno-deprecated-declarations
 #CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/
 LIBCDSA = $(LIBCDSPATH)/lib/libcds.a
 LIBRLCSA = incbwt/rlcsa.a
 LIBLZTRIE = lzindex/lztrie.a
 LIBSWCSA = swcsa/swcsa.a
+LIBS=  ${LIBRLCSA} ${LIBCDSA} ${LIBLZTRIE} ${LIBSWCSA}
 
 dcover_obs = dcover/difference_cover.o
 
 TextCollection_obs = TextCollection.o TextCollectionBuilder.o FMIndexBuilder.o RLCSABuilder.o FMIndex.o Tools.o \
-                     TextStorage.o Query.o EditDistance.o ResultSet.o ${LIBRLCSA} ${LIBCDSA} ${LIBLZTRIE} ${LIBSWCSA}
+                     TextStorage.o Query.o EditDistance.o ResultSet.o
 TCDebug_obs =  bittree.o rbtree.o dynFMI.o 
 
+TEXTCOLLECTION_A=libTextCollection.a
+
 all: testTextCollection
 
-testTextCollection: testTextCollection.o $(TextCollection_obs) $(TCDebug_obs) HeapProfiler.o
-       $(CC) -o testTextCollection testTextCollection.o $(TextCollection_obs) $(TCDebug_obs) HeapProfiler.o
+testTextCollection: testTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs) HeapProfiler.o
+       $(CC) -o testTextCollection testTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs) HeapProfiler.o
 
-timeTextCollection: timeTextCollection.o $(TextCollection_obs) $(TCDebug_obs)
+timeTextCollection: timeTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs)
        $(CC) -o timeTextCollection timeTextCollection.o $(TextCollection_obs) $(TCDebug_obs)
 
 test2dRange: test2dRange.o ${LIBCDSA}
@@ -33,6 +37,24 @@ lzindex/lztrie.a:
 swcsa/swcsa.a:
        @make -C swcsa
 
+%o: %c
+       @echo [C] $@
+       $(HIDE) (gcc -c $(CPPFLAGS) $< -o $@
+
+%o: %cpp
+       @echo [C++] $@
+       $(HIDE) $(CC) -c $(CPPFLAGS)  $< -o $@
+
+
+$(TEXTCOLLECTION_A): $(TextCollection_obs) $(LIBS)
+       @echo [Link] $@
+       $(HIDE) rm -rf .objs
+       $(HIDE) mkdir .objs
+       $(HIDE) (cd .objs; ar x ../${LIBRLCSA};ar x ../${LIBLZTRIE}; ar x ../${LIBSWCSA})
+       $(HIDE) ar rcs $@ $(TextCollection_obs) .objs/*.o
+#      $(HIDE) rm -rf .objs
+
+
 clean:
        @make clean -C incbwt
        @make clean -C lzindex
index 1d07e36..cdd5672 100644 (file)
@@ -32,7 +32,7 @@ wcsa: intIndexPackage buildFacade.o parameters.o hash.o valstring.o MemoryManage
        mv bitmap.o bitmapswcsa.o
        mv parameters.o parametswcsa.o
        ar rc $(LIBINTINDEX) parametswcsa.o buildFacade.o hashswcsa.o valstring.o MemoryManager.o basicsswcsa.o \
-               bitmapswcsa.o huffDecswcsa.o huffswcsa.o fileInfo.o 
+               bitmapswcsa.o huffDecswcsa.o huffswcsa.o fileInfo.o
        mv $(LIBINTINDEX) $(LIBINDEX)
 
 ################# SELF INDEX ON INTEGERS ##############################
@@ -44,10 +44,10 @@ intIndexPackage:
 
 ####################### UTILS MODULES #################################
 
-parameters.o: 
-       $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/parameters.c 
+parameters.o:
+       $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/parameters.c
 
-fileInfo.o:  
+fileInfo.o:
        $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/fileInfo.c
 
 hash.o: MemoryManager.o
@@ -57,28 +57,28 @@ hash.o: MemoryManager.o
 MemoryManager.o:
        $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/MemoryManager.c
 
-valstring.o:  
-       $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/valstring.c   
+valstring.o:
+       $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/valstring.c
 
-huff.o: 
+huff.o:
        $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/huff.c
 
-huffDec.o: 
+huffDec.o:
        $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/huffDec.c
 
 
-basics.o: 
+basics.o:
        $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/basics.c
 
-bitmap.o: 
+bitmap.o:
        $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/bitmap.c
 
 
 ############################ CLEANING #################################
 
-cleanO: 
+cleanO:
        rm -f *.o
-       
+
 clean:
        cd  $(SRCDIRCSA) && $(MAKE) clean -w
        rm -rf *~ *% *.o core *.bak $(LIBINTINDEX) $(LIBINDEX)
index 3647e99..b581059 100755 (executable)
@@ -823,7 +823,7 @@ int build_WCSA (uchar *text, ulong length, char *build_options, void **index) {
                tmpOffsets[zeroNode]=tmpOffset; //setting pointer to the "virtual" word {zeroNode+1}^{th}
                
                //kbit encoding of the offsets
-               uint elemSize = bits(tmpOffset);
+               uint elemSize = _bits(tmpOffset);
                wcsa->wordsData.elemSize = elemSize;
                wcsa->wordsData.words = (uint *) malloc (((((zeroNode +1)*elemSize)+W-1) /W) * sizeof(uint));  //with 1 extra slot !.
                wcsa->wordsData.words[((((zeroNode +1)*elemSize)+W-1) /W)   -1 ] =0000;
index 3fb9c0c..8f02954 100755 (executable)
@@ -5,7 +5,7 @@ CC          = g++
 
 ifndef CFLAGS  ##possibly already defined by the "main Makefile".
        ##CFLAGS = -O9 -m32
-       CFLAGS      = -O9 -m32 
+       CFLAGS      = -O9 -m32
        ##CFLAGS      = -g -m32 -O0
 endif
 
@@ -15,41 +15,41 @@ all: intIndex cleanO
 
 
 intIndex: icsa.o parameters.o basics.o huff.o bitmap.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
-       ar rc $(LIBINTINDEX) icsa.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o  
+       ar rc $(LIBINTINDEX) icsa.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
                        #not including "parameters.o basics.o bitmap.o huff.o" as they are included by wcsa
                        #they are already included into the library by the presentation layer.
 
-icsa.o: parameters.o basics.o bitmap.o huff.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o 
-        $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/icsa.c 
+icsa.o: parameters.o basics.o bitmap.o huff.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
+        $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/icsa.c
 
 psiHuffmanRLE.o: huff.o
-       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiHuffmanRLE.c 
+       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiHuffmanRLE.c
 
 psiDeltaCode.o:
-       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiDeltaCode.c 
+       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiDeltaCode.c
 
 psiGonzalo.o: huff.o
-       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiGonzalo.c 
+       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiGonzalo.c
 
-parameters.o: 
-       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/parameters.c 
-       
-       
-huff.o: 
+parameters.o:
+       $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/parameters.c
+
+
+huff.o:
        $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/huff.c
 
-basics.o: 
+basics.o:
        $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/basics.c
 
-bitmap.o: 
+bitmap.o:
        $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/bitmap.c
 
 
-cleanO: 
+cleanO:
        rm -f *.o
-       
+
 clean:
-       rm -rf *~ *% *.o core *.bak icsa.a 
+       rm -rf *~ *% *.o core *.bak icsa.a
 
 tar:
        tar czvf icsa.tar.gz  Makefile
index 102832c..523859d 100644 (file)
@@ -1 +1 @@
-#include <stdio.h>\r#include <fcntl.h>\r#include <sys/stat.h>\r#include <time.h>\r#include <sys/time.h>\r\r#include "defValues.h"\r#include "../utils/bitmap.h"\r#include "../utils/huff.h"\r#include "../utils/parameters.h"\r\r#ifdef PSI_HUFFMANRLE\r   #include "psiHuffmanRLE.h"\r#endif\r\r#ifdef PSI_GONZALO\r  #include "psiGonzalo.h"\r#endif\r\r#ifdef PSI_DELTACODES\r  #include "psiDeltaCode.h"\r#endif\r\r\rtypedef struct {\r    uint suffixArraySize;\r  uint T_Psi;\r    uint *D;\r       bitmap bD;\r     uint T_A;\r      uint T_AInv;\r   uint *samplesA;\r        uint samplesASize;\r     uint *BA;\r      bitmap bBA;     \r       uint *samplesAInv;\r     uint samplesAInvSize;\r  uint displayCSAState;\r  int displayCSAPrevPosition;\r    #ifdef PSI_HUFFMANRLE   \r       HuffmanCompressedPsi hcPsi;\r    #endif  \r       #ifdef PSI_GONZALO\r     GonzaloCompressedPsi gcPsi;\r    #endif\r #ifdef PSI_DELTACODES\r  DeltaCompressedPsi dcPsi;\r      #endif\r \r       //only needed during "parse_parameters".\r       uint tempNSHUFF;\r       uint psiSearchFactorJump;  //factor of the T_Psi value.\r} ticsa;        \r\r      \r// FUNCTION PROTOTYPES: BUILDING THE INDEX\r\r//Creates the ICSA \r\r      int buildIntIndex (uint *intVector, uint n, char *build_options, void **index ); //ticsa *createIntegerCSA (uint **aintVector, uint SAsize, char *build_options);\r\r//Returns number of elements in the indexed sequence of integers\r    int sourceLenIntIndex(void *index, uint *numInts);\r\r//Save the index to disk\r   int saveIntIndex(void *index, char *pathname); //void storeStructsCSA(ticsa *myicsa, char *basename);\r\r// Loads the index from disk.\r   int loadIntIndex(char *pathname, void **index);  //ticsa *loadCSA(char *basename);\r\r//  Frees memory    \r       int freeIntIndex(void *index); //uint destroyStructsCSA(ticsa *myicsa);\r\r//Returns the size (in bytes) of the index over the sequence of integers.\r     int sizeIntIndex(void *index, uint *numBytes); //uint CSA_size(ticsa *myicsa);  \r\r      // Shows detailed summary info of the self-index (memory usage of each structure)\rint printInfoIntIndex(void *index, const char tab[]);\r\r//Number of occurrences of the pattern, and the interval [left,right] in the suffix array.\r    int countIntIndex(void *index, uint *pattern, uint length, ulong *numocc, ulong *left, ulong *right);\r                  //uint countCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right);               // Exponential search\r                  //uint countCSABin(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right);    // Binary search\r\r// Returns an array with integers corresponding offsets to the occurrences of the pattern, \r// as well as the number of occurrences\r  int locateIntIndex(void *index, uint *pattern, uint length, ulong **occ, ulong *numocc);\r               //uint *locateCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *occ);\r\r//Returns the value of the source (array of integers) at a given offset.\r// (that is, the element "position" from the original array of uints)\r  int displayIntIndex(void *index, ulong position, uint *value);\r         //uint displayCSA(ticsa *myicsa, uint position);        \r\r\r/* Private function prototypes ********************************************/\ruint parametersCSA(ticsa *myicsa, char *build_options);\r\ruint displayCSAFirst(ticsa *myicsa, uint position);\ruint displayCSANext(ticsa *myicsa);\rint  SadCSACompare(ticsa *myicsa, uint *pattern, uint patternSize, uint p);\ruint A(ticsa *myicsa, uint position);\ruint inverseA(ticsa *myicsa, uint offset);\r\rvoid showStructsCSA(ticsa *myicsa);              // For Debugging\r\r
\ No newline at end of file
+//#include <stdio.h>\r#include <fcntl.h>\r#include <sys/stat.h>\r#include <time.h>\r#include <sys/time.h>\r\r#include "defValues.h"\r#include "../utils/bitmap.h"\r#include "../utils/huff.h"\r#include "../utils/parameters.h"\r\r#ifdef PSI_HUFFMANRLE\r #include "psiHuffmanRLE.h"\r#endif\r\r#ifdef PSI_GONZALO\r  #include "psiGonzalo.h"\r#endif\r\r#ifdef PSI_DELTACODES\r  #include "psiDeltaCode.h"\r#endif\r\r\rtypedef struct {\r    uint suffixArraySize;\r  uint T_Psi;\r    uint *D;\r       bitmap bD;\r     uint T_A;\r      uint T_AInv;\r   uint *samplesA;\r        uint samplesASize;\r     uint *BA;\r      bitmap bBA;     \r       uint *samplesAInv;\r     uint samplesAInvSize;\r  uint displayCSAState;\r  int displayCSAPrevPosition;\r    #ifdef PSI_HUFFMANRLE   \r       HuffmanCompressedPsi hcPsi;\r    #endif  \r       #ifdef PSI_GONZALO\r     GonzaloCompressedPsi gcPsi;\r    #endif\r #ifdef PSI_DELTACODES\r  DeltaCompressedPsi dcPsi;\r      #endif\r \r       //only needed during "parse_parameters".\r       uint tempNSHUFF;\r       uint psiSearchFactorJump;  //factor of the T_Psi value.\r} ticsa;        \r\r      \r// FUNCTION PROTOTYPES: BUILDING THE INDEX\r\r//Creates the ICSA \r\r      int buildIntIndex (uint *intVector, uint n, char *build_options, void **index ); //ticsa *createIntegerCSA (uint **aintVector, uint SAsize, char *build_options);\r\r//Returns number of elements in the indexed sequence of integers\r    int sourceLenIntIndex(void *index, uint *numInts);\r\r//Save the index to disk\r   int saveIntIndex(void *index, char *pathname); //void storeStructsCSA(ticsa *myicsa, char *basename);\r\r// Loads the index from disk.\r   int loadIntIndex(char *pathname, void **index);  //ticsa *loadCSA(char *basename);\r\r//  Frees memory    \r       int freeIntIndex(void *index); //uint destroyStructsCSA(ticsa *myicsa);\r\r//Returns the size (in bytes) of the index over the sequence of integers.\r     int sizeIntIndex(void *index, uint *numBytes); //uint CSA_size(ticsa *myicsa);  \r\r      // Shows detailed summary info of the self-index (memory usage of each structure)\rint printInfoIntIndex(void *index, const char tab[]);\r\r//Number of occurrences of the pattern, and the interval [left,right] in the suffix array.\r    int countIntIndex(void *index, uint *pattern, uint length, ulong *numocc, ulong *left, ulong *right);\r                  //uint countCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right);               // Exponential search\r                  //uint countCSABin(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right);    // Binary search\r\r// Returns an array with integers corresponding offsets to the occurrences of the pattern, \r// as well as the number of occurrences\r  int locateIntIndex(void *index, uint *pattern, uint length, ulong **occ, ulong *numocc);\r               //uint *locateCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *occ);\r\r//Returns the value of the source (array of integers) at a given offset.\r// (that is, the element "position" from the original array of uints)\r  int displayIntIndex(void *index, ulong position, uint *value);\r         //uint displayCSA(ticsa *myicsa, uint position);        \r\r\r/* Private function prototypes ********************************************/\ruint parametersCSA(ticsa *myicsa, char *build_options);\r\ruint displayCSAFirst(ticsa *myicsa, uint position);\ruint displayCSANext(ticsa *myicsa);\rint  SadCSACompare(ticsa *myicsa, uint *pattern, uint patternSize, uint p);\ruint A(ticsa *myicsa, uint position);\ruint inverseA(ticsa *myicsa, uint offset);\r\rvoid showStructsCSA(ticsa *myicsa);              // For Debugging\r\r
\ No newline at end of file
index ee8f086..f5e4715 100644 (file)
@@ -71,8 +71,8 @@ GonzaloCompressedPsi gonzaloCompressPsi(uint *Psi, uint psiSize, uint T, uint HU
        Hacc = createHuff (acc,HUFF-1, UNSORTED);
        Hlen = createHuff (lacc,samplen-2, UNSORTED);
        totexc = acc[0];
-       pslen = bits(psiSize+1);
-       _bplen = bits(Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen);
+       pslen = _bits(psiSize+1);
+       _bplen = _bits(Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen);
        _bposS = (uint *)malloc ((((1+links/samplen)*_bplen+W-1)/W)*sizeof(uint));
        _cPsi  = (uint *)malloc (((Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen+W-1)/W)*sizeof(uint));  
        
index ac619a1..c5b9451 100644 (file)
@@ -67,11 +67,11 @@ HuffmanCompressedPsi huffmanCompressPsi(unsigned int *Psi, unsigned int psiSize,
                                else
                                        if(diffs[index]<0) {    // Valor negativo
                                                absolute_value = -diffs[index];
-                                               binaryLenght = bits(absolute_value);
+                                               binaryLenght = _bits(absolute_value);
                                                huffmanDst[binaryLenght+negStart-1]++;
                                        } else {                                // Valor grande >= 128
                                                absolute_value = diffs[index];
-                                               binaryLenght = bits(absolute_value);
+                                               binaryLenght = _bits(absolute_value);
                                                huffmanDst[binaryLenght+bigStart-1]++;
                                        }
                        }
@@ -99,8 +99,8 @@ HuffmanCompressedPsi huffmanCompressPsi(unsigned int *Psi, unsigned int psiSize,
        
        // Calculamos o numero de mostras e o espacio ocupado por cada mostra e por cada punteiro
        numberOfSamples = (psiSize+T-1)/T;      
-       sampleSize = bits(psiSize);
-       pointerSize = bits(streamSize); 
+       sampleSize = _bits(psiSize);
+       pointerSize = _bits(streamSize);        
 
        // Reservamos espacio para a secuencia e para as mostras e punteiros
        samples = (unsigned int *)malloc(sizeof(uint)*((numberOfSamples*sampleSize+31)/32));    
@@ -132,13 +132,13 @@ HuffmanCompressedPsi huffmanCompressPsi(unsigned int *Psi, unsigned int psiSize,
                                else
                                        if(diffs[index]<0) {    // Valor negativo
                                                absolute_value = -diffs[index];
-                                               binaryLenght = bits(absolute_value);
+                                               binaryLenght = _bits(absolute_value);
                                                ptr = encodeHuff(diffsHT,binaryLenght+negStart-1,stream,ptr);
                                                bitwrite(stream,ptr,binaryLenght,absolute_value);
                                                ptr += binaryLenght;                                            
                                        } else {                                // Valor grande >= 128
                                                absolute_value = diffs[index];
-                                               binaryLenght = bits(absolute_value);                                    
+                                               binaryLenght = _bits(absolute_value);                                   
                                                ptr = encodeHuff(diffsHT,binaryLenght+bigStart-1,stream,ptr);
                                                bitwrite(stream,ptr,binaryLenght,absolute_value);                                               
                                                ptr += binaryLenght;
index 398e975..c9cb275 100755 (executable)
@@ -1,3 +1,6 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 // Basics
 
@@ -7,9 +10,9 @@
 #include <stdlib.h>
 
                // Memory management
-       
-       void *Malloc (int n)
-       
+
+static void *Malloc (size_t n)
+
           { void *p;
             if (n == 0) return NULL;
             p = (void*) malloc (n);
                }
             return p;
           }
-       
-       void Free (void *p)
-       
-          { if (p) free (p); 
+
+static void Free (void *p)
+
+          { if (p) free (p);
           }
-       
-       void *Realloc (void *p, int n)
-       
+
+static void *Realloc (void *p, size_t n)
+
           { if (p == NULL) return Malloc (n);
             if (n == 0) { Free(p); return NULL; }
             p = (void*) realloc (p,n);
@@ -41,7 +44,7 @@
 
         // bits needed to represent a number between 0 and n
 
-uint bits (uint n)
+uint _bits (uint n)
 
    { uint b = 0;
      while (n)
@@ -68,7 +71,7 @@ uint bitread (uint *e, uint p, uint len)
 
        // writes e[p..p+len-1] = s, len <= W
 
-void bitwrite (register uint *e, register uint p, 
+void bitwrite (register uint *e, register uint p,
               register uint len, register uint s)
 
    { e += p/W; p %= W;
@@ -89,7 +92,7 @@ void bitwrite (register uint *e, register uint p,
    }
        // writes e[p..p+len-1] = 0
 
-void bitzero2 (register uint *e, register uint p, 
+void bitzero2 (register uint *e, register uint p,
               register uint len)
 
    { e += p/W; p %= W;
@@ -105,3 +108,6 @@ void bitzero2 (register uint *e, register uint p,
      if (len > 0)
        *e &= ~(((1<<len)-1)<<p);
    }
+#ifdef __cplusplus
+}
+#endif
index 6e4b39b..8e2f820 100755 (executable)
@@ -5,6 +5,10 @@
 #ifndef BASICSINCLUDED
 #define BASICSINCLUDED
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
   // Includes 
 
 #include <sys/types.h>
 
   // Memory management
 
-#define malloc(n) Malloc(n)
-#define free(p) Free(p)
-#define realloc(p,n) Realloc(p,n)
+  //#define malloc(n) Malloc(n)
+  //#define free(p) Free(p)
+  //#define realloc(p,n) Realloc(p,n)
 
-void *Malloc (int n);
-void Free (void *p);
-void *Realloc (void *p, int n);
+static void *Malloc (size_t n);
+static void Free (void *p);
+static void *Realloc (void *p, size_t n);
 
   // Data types
 
@@ -49,7 +53,7 @@ void *Realloc (void *p, int n);
 #define W (32)
 
        // bits needed to represent a number between 0 and n
-uint bits (uint n);
+uint _bits (uint n);
         // returns e[p..p+len-1], assuming len <= W
 uint bitread (uint *e, uint p, uint len);
         // writes e[p..p+len-1] = s, assuming len <= W
@@ -108,5 +112,8 @@ void bitzero2 (uint *e, uint p, uint len);
            } \
          } \
    } 
+#ifdef __cplusplus
+ }
+#endif
 
 #endif