Last active
January 10, 2019 03:57
-
-
Save justenwalker/9c925c662690d25c0782d67bfe510939 to your computer and use it in GitHub Desktop.
Iterate through each array entry using unsafe.Pointer arithmetic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rows := make([]_MIB_TCPROW_OWNER_PID,int(pTable.dwNumEntries)) | |
for i := 0; i < int(pTable.dwNumEntries); i++ { | |
rows[i] = *(*_MIB_TCPROW_OWNER_PID)(unsafe.Pointer( | |
uintptr(unsafe.Pointer(&pTable.table[0])) + | |
uintptr(i) * unsafe.Sizeof(pTable.table[0]) | |
)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment