diff options
Diffstat (limited to '')
-rw-r--r-- | utils/clen.go | 11 |
1 files changed, 11 insertions, 0 deletions
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) +} |