title: c++ sqllite3 reading blob won't work
body: <p>Can someone guide me please,</p>
  
  <p>I can't seem to read my blob correctly.</p>
  
  <p>I don't know what's wrong, can somebody help?</p>
  
  <p>this is my function:</p>
  
  <p>what i'm trying to do is:</p>
  
  <p>read the bob as binary and store the bytes in a char *data;</p>
  
  <p>can someone please help?</p>
  
  <pre><code>    int baramdb::dbreadblob(int pid)
  {
      sqlite3_stmt *res;
  
      const char *tail;
      int count = 0;
      this-&gt;dbopen(this-&gt;dbfile); 
  
      if (sqlite3_prepare_v2(this-&gt;db, "SELECT * FROM Packet_Send_Queue", 128, &amp;res, &amp;tail) != SQLITE_OK)
      {
          printf("[Baram] Can't retrieve data: %s\n", sqlite3_errmsg(db));
          sqlite3_close(db);
          return(1);
      }
  
      while (sqlite3_step(res) == SQLITE_ROW)
      {
  
          int *plength = 0;       
          *plength = sqlite3_column_bytes(res, 2);
  
          unsigned char **pbuffer = (unsigned char **)malloc(*plength);
  
          memcpy(*pbuffer, sqlite3_column_blob(res, 0), *plength);
          count++;
      }
  
      sqlite3_close(this-&gt;db);        
      this-&gt;lastresult = count;
  
      return count;
  }
  </code></pre>