diff options
Diffstat (limited to 'pkg/utils/clen.go')
-rw-r--r-- | pkg/utils/clen.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/utils/clen.go b/pkg/utils/clen.go new file mode 100644 index 0000000..17d1c4b --- /dev/null +++ b/pkg/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) +} |