(Readding the list cc:)

On Tue, Jan 29, 2013 at 4:32 PM, David Granados <[email protected]> wrote:
> Does not work :-(
>
> Size of proto before: 196, size of proto after gzip: 196

What measures this? Nothing in any code you quoted.

> Now my code are:
> 206 template <class T> int
>       207 Proto<T>::CompressProtoToString(std::string& pOut,T pProto)

You never touch pOut.

>       208 {
>       209   // Resultado
>       210   int l_resultado = -1;
>       211
>
>       212   // Definimos el buffer al cual vamos a comprimir
>       213   const unsigned bufLength = 256;
>       214   unsigned char buffer[bufLength];
>       215
>       216   memset(buffer,0,256);
>       217
>       218
>       219   std::cout << buffer << std::endl;
>       220
>       221   // Obtenemos un array del proto serializado
>       222   ZeroCopyOutputStream* output = new
> google::protobuf::io::ArrayOutputStream(buffer,bufLength);
>       223   // Introducimos las opciones de compression
>       224   GzipOutputStream::Options options;
>       225   options.format = GzipOutputStream::GZIP;
>       226   options.compression_level = NIVEL_COMPRESION;

What is the value of NIVEL_COMPRESION?

>       227
>       228   google::protobuf::io::GzipOutputStream
> gzip_stream(output,options);
>       229   if (!pProto.SerializeToZeroCopyStream(&gzip_stream))
>       230   {
>       231     std::cerr << "Error comprimiendo el proto a string." <<
> std::endl;
>       232   }
>       233   gzip_stream.Close();
>       234   std::cout << ":"  << buffer << std::endl;

This will fail if any 0-bytes happen to get serialized (you're
treating buffer as a nul-terminated C-style string)

>       235
>       236   // Devolvemos el resultado
>       237   return l_resultado;
>       238 }
>

I suggest that you post a *complete*, compilable, testcase - it's just
too hard to diagnose what's going wrong by guessing what you are doing
in the surrounding code that you didn't provide.

Oliver

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to