I am trying to use this example but it always return write_len = 10 bytes.
ThriftTransport* transport = THRIFT_TRANSPORT(
g_object_new(THRIFT_TYPE_MEMORY_BUFFER, "buf_size", 8096, NULL));
ThriftProtocol* protocol = THRIFT_PROTOCOL(
g_object_new(THRIFT_TYPE_BINARY_PROTOCOL, "transport", transport,
NULL));
Exception* src = g_object_new(TYPE_EXCEPTION, NULL);
ExceptionClass* cls = EXCEPTION_GET_CLASS(src);
g_object_set(src,
"ex_sign", exception_signature,
"cl_sign", class_signature,
"caught", catch_method != NULL,
NULL);
int write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
This was a bug in the C (GLib) implementation that was reported and fixed just recently, so you'll need to fetch and build the latest Thrift source from git for the example to work correctly.
If you're curious, you can see the discussion on the user mailing list that led to the bug being identified.