aboutsummaryrefslogtreecommitdiff
path: root/ber/bitstring.go
diff options
context:
space:
mode:
Diffstat (limited to 'ber/bitstring.go')
-rw-r--r--ber/bitstring.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/ber/bitstring.go b/ber/bitstring.go
index 7e0fd93..eabc354 100644
--- a/ber/bitstring.go
+++ b/ber/bitstring.go
@@ -54,9 +54,17 @@ func (bs BitString) IsSet(n int) bool {
return bs[n]
}
+func pow2(n int) int {
+ i := 1
+ for i < n+1 {
+ i <<= 1
+ }
+ return i
+}
+
func (bs *BitString) Set(n int) {
if len(*bs) < n {
- nbs := make(BitString, n+1)
+ nbs := make(BitString, pow2(n))
copy(nbs, *bs)
*bs = nbs
}
@@ -65,7 +73,7 @@ func (bs *BitString) Set(n int) {
func (bs *BitString) Clear(n int) {
if len(*bs) < n {
- nbs := make(BitString, n+1)
+ nbs := make(BitString, pow2(n))
copy(nbs, *bs)
*bs = nbs
}