Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
c4a3e2f6
Commit
c4a3e2f6
authored
Mar 31, 2015
by
Kyle Jones
Committed by
Wouter van Oortmerssen
Apr 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always add additional space if no more is available
Change-Id: If08b2d839489d40e977de794b13584fa66ff32c1
parent
803f9bba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
builder.go
go/builder.go
+1
-1
go_test.go
tests/go_test.go
+16
-1
No files found.
go/builder.go
View file @
c4a3e2f6
...
...
@@ -198,7 +198,7 @@ func (b *Builder) Prep(size, additionalBytes int) {
alignSize
&=
(
size
-
1
)
// Reallocate the buffer if needed:
for
int
(
b
.
head
)
<
alignSize
+
size
+
additionalBytes
{
for
int
(
b
.
head
)
<
=
alignSize
+
size
+
additionalBytes
{
oldBufSize
:=
len
(
b
.
Bytes
)
b
.
growByteBuffer
()
b
.
head
+=
UOffsetT
(
len
(
b
.
Bytes
)
-
oldBufSize
)
...
...
tests/go_test.go
View file @
c4a3e2f6
...
...
@@ -21,12 +21,13 @@ import (
"bytes"
"flag"
"fmt"
flatbuffers
"github.com/google/flatbuffers/go"
"io/ioutil"
"os"
"reflect"
"sort"
"testing"
flatbuffers
"github.com/google/flatbuffers/go"
)
var
(
...
...
@@ -479,6 +480,20 @@ func CheckByteLayout(fail func(string, ...interface{})) {
b
.
EndVector
(
2
)
check
([]
byte
{
2
,
0
,
0
,
0
,
2
,
1
,
0
,
0
})
// padding
// test 3b: 11xbyte vector matches builder size
b
=
flatbuffers
.
NewBuilder
(
12
)
b
.
StartVector
(
flatbuffers
.
SizeByte
,
8
,
1
)
start
:=
[]
byte
{}
check
(
start
)
for
i
:=
1
;
i
<
12
;
i
++
{
b
.
PrependByte
(
byte
(
i
))
start
=
append
([]
byte
{
byte
(
i
)},
start
...
)
check
(
start
)
}
b
.
EndVector
(
8
)
check
(
append
([]
byte
{
8
,
0
,
0
,
0
},
start
...
))
// test 4: 1xuint16 vector
b
=
flatbuffers
.
NewBuilder
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment