From bcfaffac240d74cd79bec3c2a9d3c144d215b495 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 22 Feb 2020 11:57:50 +0100 Subject: Added tests to the state package, and reworked the code around that --- utils/clen.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 utils/clen.go (limited to 'utils/clen.go') diff --git a/utils/clen.go b/utils/clen.go new file mode 100644 index 0000000..17d1c4b --- /dev/null +++ b/utils/clen.go @@ -0,0 +1,11 @@ +package utils + +// Clen returns the length of a null terminated string like in C +func Clen(n []byte) int { + for i := 0; i < len(n); i++ { + if n[i] == 0 { + return i + } + } + return len(n) +} -- cgit v1.2.3