Skip to content

Commit

Permalink
Cleanup binaryReaderFrom
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
  • Loading branch information
jkroepke committed Jul 15, 2023
1 parent 8b9c9a5 commit 3a61935
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
5 changes: 1 addition & 4 deletions perflib/perflib.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ type PerfCounter struct {
}

// Error value returned by RegQueryValueEx if the buffer isn't sufficiently large
const errorMoreData = syscall.Errno(234)
const errorMoreData = syscall.Errno(syscall.ERROR_MORE_DATA)

var (
bufLenGlobal = uint32(400000)
Expand Down Expand Up @@ -209,8 +209,6 @@ func queryRawData(query string) ([]byte, error) {
return nil, fmt.Errorf("failed to encode query string: %v", err)
}

defer syscall.RegCloseKey(syscall.HKEY_PERFORMANCE_DATA)

for {
bufLen := uint32(len(buffer))

Expand All @@ -226,7 +224,6 @@ func queryRawData(query string) ([]byte, error) {
newBuffer := make([]byte, len(buffer)+16384)
copy(newBuffer, buffer)
buffer = newBuffer
syscall.RegCloseKey(syscall.HKEY_PERFORMANCE_DATA)
continue
} else if err != nil {
if errno, ok := err.(syscall.Errno); ok {
Expand Down
4 changes: 0 additions & 4 deletions perflib/raw_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
"syscall"
)

type binaryReaderFrom interface {
BinaryReadFrom(r io.Reader) error
}

/*
perfDataBlock
See: https://msdn.microsoft.com/de-de/library/windows/desktop/aa373157(v=vs.85).aspx
Expand Down

0 comments on commit 3a61935

Please sign in to comment.