aboutsummaryrefslogtreecommitdiff
path: root/utils/clen.go
blob: 17d1c4bed955e362b641ec80e55200ee56b2dc42 (plain)
1
2
3
4
5
6
7
8
9
10
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)
}