lvzixun / sproto-Csharp

A pure C# implementation of sproto.
140 stars 53 forks source link

当field数量超过32时会出错 #3

Closed helloqinglan closed 9 years ago

helloqinglan commented 9 years ago

SprotoTypeFieldOP.cs中

public SprotoTypeFieldOP (int max_field_count) { int slot_count = max_field_count / slot_bits_size; slot_count = (slot_count > 0)?(slot_count):(1);

this.has_bits = new UInt32[slot_count]; }

slot_count的计算有误 可以修改为

int slot_count = (max_field_count + slot_bits_size - 1) / slot_bits_size;

或者添加

if (max_field_count % slot_bits_size > 0) slot_count++;

lvzixun commented 9 years ago

thanks~~