title: using lzo library in c++ application
body: <p>I got lzo library to use in our application. The version was provided is 1.07. 
  They have given me .lib along with some header file and some .c source files.</p>
  
  <p>I have setup test environment as per specs. I am able to see lzo routine functions in my application.</p>
  
  <p>Here is my test application</p>
  
  <pre><code>#include "stdafx.h"
  #include "lzoconf.h"
  #include "lzo1z.h"
  #include &lt;stdlib.h&gt;
  
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      FILE * pFile;
      long lSize;
      unsigned char *i_buff;
      unsigned char *o_buff;
  
      int i_len,e = 0;
      unsigned int o_len;
  
      size_t result;
  
      //data.txt have a single compressed packet 
      pFile = fopen("data.txt","rb");
  
      if (pFile==NULL) 
          return -1;
  
      // obtain file size:
      fseek (pFile , 0 , SEEK_END);
      lSize = ftell (pFile);
      rewind (pFile);
  
      // allocate memory to contain the whole file:
      i_buff = (unsigned char*) malloc (sizeof(char)*lSize);
      if (i_buff == NULL) 
          return -1;
  
      // copy the file into the buffer:
      result = fread (i_buff,1,lSize,pFile);
      if (result != lSize) 
          return -1;
  
      i_len = lSize;
      o_len = 512;
  
      // allocate memory for output buffer
      o_buff = (unsigned char*) malloc(sizeof(char)*o_len);
  
      if (o_buff == NULL) 
          return -1;
       lzo_memset(o_buff,0,o_len);    
      lzo1z_decompress(i_buff,i_len,o_buff,&amp;o_len,NULL);
  
      return 0;   
  }
  </code></pre>
  
  <p>It gives access violation on last line.</p>
  
  <pre><code>lzo1z_decompress(i_buff,i_len,o_buff,&amp;o_len,NULL);
  </code></pre>
  
  <p>in provided library signature for above functiion is</p>
  
  <pre><code>lzo1z_decompress        ( const lzo_byte *src, lzo_uint  src_len,
                                  lzo_byte *dst, lzo_uint *dst_len,
                                  lzo_voidp wrkmem /* NOT USED */ );
  </code></pre>
  
  <p>What is wrong?</p>