summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/andybalholm/brotli/memory.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/andybalholm/brotli/memory.go')
-rw-r--r--vendor/github.com/andybalholm/brotli/memory.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/vendor/github.com/andybalholm/brotli/memory.go b/vendor/github.com/andybalholm/brotli/memory.go
new file mode 100644
index 0000000000..7208a3bbf6
--- /dev/null
+++ b/vendor/github.com/andybalholm/brotli/memory.go
@@ -0,0 +1,56 @@
+package brotli
+
+/* Copyright 2016 Google Inc. All Rights Reserved.
+
+ Distributed under MIT license.
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+*/
+
+/*
+Dynamically grows array capacity to at least the requested size
+T: data type
+A: array
+C: capacity
+R: requested size
+*/
+func brotli_ensure_capacity_uint8_t(a *[]byte, c *uint, r uint) {
+ if *c < r {
+ var new_size uint = *c
+ if new_size == 0 {
+ new_size = r
+ }
+
+ for new_size < r {
+ new_size *= 2
+ }
+ var new_array []byte = make([]byte, new_size)
+ if *c != 0 {
+ copy(new_array, (*a)[:*c])
+ }
+
+ *a = new_array
+ *c = new_size
+ }
+}
+
+func brotli_ensure_capacity_uint32_t(a *[]uint32, c *uint, r uint) {
+ var new_array []uint32
+ if *c < r {
+ var new_size uint = *c
+ if new_size == 0 {
+ new_size = r
+ }
+
+ for new_size < r {
+ new_size *= 2
+ }
+
+ new_array = make([]uint32, new_size)
+ if *c != 0 {
+ copy(new_array, (*a)[:*c])
+ }
+
+ *a = new_array
+ *c = new_size
+ }
+}