Thanks to everyone trying to help me here is a big issue here, I have something about sysctl The example code has been found and extended so that I can query the network interface for my in / out data. When I run this code directly in the main (), everything works fine (though no NSUATOrepool), though once I add it to my class and execute it, then I get errors & amp; Segfaults. I have tracked down this issue on NSAIDERIPIPALS Can anyone help? (If you do not believe it, then just keep NSAIDRecipital * pool = [[NSAUT Oraipal Alok]] IIT, before code and keep the whole thing in main ()
int mib [ ] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST,}} int alloc; Struct if_msghdr * ifm, * nextifm; Struct sockaddr_dl * sdl; char * lim, * next; Size_t requirement; four [32]; four * Buf; if (sysctl (mib, 6, null, & required, zero, 0) & lt; 0) return 0; if (allocation is required) {buf = malloc (required); if (buf == NULL returns 0; Alloc = required;} if (sysctl (mib, 6, buf, and required, zero, 0) & lt; 0) back 0; lim = buf + required; next = buf; while (next & lt; lim) {ifm = (struct if_msghdr *) next; if (ifm-> ifm_type! = RTM_IFINFO) 0; next + = ifm-> ifm_msglen; while (next & lt; lim) {nextifm = (straight if_msghdr *) Next; if break (nextifm-> ifm_type! = RTM_NEWADDR); Next + = NextFim- Gt; ifm_msglen;} if (ifm! = NULL & amp; amp;> ifm_flags & amp; IFF_UP) {SDL = (struct sockaddr_dl *) (ifm + 1); If (SDL-> SDL_Family! = AF_LINK) will continue; Strncpy (s, sdl- & gt; sdl_data, sdl- & gt; sdl_nlen); S [sdl- & gt; Sdl_nlen] = '\ 0'; NSLog (@ "Interface% s in% qu in% qu \ n", s, (UInt64) ifm-> ifm_data.ifi_ibytes, (UInt64) ifm-> ifm_data.ifi_obytes); }}
NSAutoreleasePool That you have a problem with memory allocation, double release, hanging pointers or unpaid data. In your case, this is the unused data. You do not initiate the alloc variable as a result, it is completely random that allocated to buf Has been or is pointing to some random memory place.
Comments
Post a Comment