int PriceInfo::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // required int32 price = 1; if (has_price()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->price()); } // required int32 size = 2; if (has_size()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->size()); } // required .acm.Side side = 3; if (has_side()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->side()); } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; }
void* alloc_int(size_t size, u8int align, heap_t* heap) { header_t* head = (header_t*)(heap->start_addr); while(head->magic==MAGIC_USED || !has_size(head,size,align)) head = next_head(head); if(head->magic!=MAGIC_FREE) return (void*)0; if(align) { u32int diff = ALIGN((u32int)head + sizeof(header_t))-sizeof(header_t)-(u32int)head; if((u32int)head+diff+sizeof(header_t) > heap->end_addr) { expand((u32int)head + diff + sizeof(header_t) - heap->start_addr, heap); } footer_t f = *(footer_t*)((u32int)head-sizeof(footer_t)); header_t h = *head; head = (header_t*)((u32int)head + diff); footer_t* foot = (footer_t*)((u32int)head-sizeof(footer_t)); *head = h; *foot = f; foot->head->size+=diff; if(head->size != ALL_MEM) head->size-=diff; } void* ans = (void*)((u32int)head + sizeof(header_t)); if(head->size == ALL_MEM) { head->magic = MAGIC_USED; head->size = size; //Expand the heap if necessary if((u32int)head + sizeof(header_t)+head->size+sizeof(footer_t) > heap->end_addr) { expand((u32int)head + sizeof(header_t) + head->size + sizeof(footer_t) - heap->start_addr, heap); } footer_t* foot = (footer_t*)((u32int)head+sizeof(header_t)+head->size); foot->head = head; header_t* next = (header_t*)((u32int)foot+sizeof(footer_t));; next->magic = MAGIC_FREE; next->size = ALL_MEM; } else if(head->size - size - sizeof(header_t) - sizeof(footer_t) > 0) { footer_t *foot, *next_foot; next_foot = (footer_t*)((u32int)head + head->size + sizeof(header_t)); foot = (footer_t*)((u32int)head + size + sizeof(header_t)); header_t *next = next_head(head); next->size = head->size - size - sizeof(header_t) - sizeof(footer_t); head->magic = MAGIC_USED; head->size = size; foot->head = head; next->magic = MAGIC_FREE; next_foot->head = next; } else { head->magic = MAGIC_USED; } return ans; }
void PriceInfo::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // required int32 price = 1; if (has_price()) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->price(), output); } // required int32 size = 2; if (has_size()) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->size(), output); } // required .acm.Side side = 3; if (has_side()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 3, this->side(), output); } if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } }
::google::protobuf::uint8* PriceInfo::SerializeWithCachedSizesToArray( ::google::protobuf::uint8* target) const { // required int32 price = 1; if (has_price()) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->price(), target); } // required int32 size = 2; if (has_size()) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->size(), target); } // required .acm.Side side = 3; if (has_side()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 3, this->side(), target); } if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } return target; }