remove protobuf_c_default_allocator
"protobuf_c_default_allocator" is the last bit of global data in libprotobuf-c, and it can be hidden with some relatively easy (though API/ABI-breaking) changes to ProtobufCBufferSimple. all exported functions that take a ProtobufCAllocator either use the provided allocator (if non-NULL), or switch to the default allocator (if NULL). there are now two relatively unambiguous choices when a ProtobufCAllocator is required by an exported function: 1) use NULL. the vast majority of callers should pick this option. 2) implement your own allocation functions, and enclose these in a ProtobufCAllocator struct. in previous versions of protobuf-c there were two other possibilities: 3) maybe use &protobuf_c_system_allocator? 4) maybe use &protobuf_c_default_allocator? this was relatively confusing, and by removing these latter two options we can avoid having global library state.
Showing
Please register or sign in to comment