/* Initialize all the allocators here. * This function should be called only once when Wireshark or TShark starts * up. */ void emem_init(void) { ep_init_chunk(); se_init_chunk(); if (getenv("WIRESHARK_DEBUG_SCRUB_MEMORY")) debug_use_memory_scrubber = TRUE; #if defined (_WIN32) /* Set up our guard page info for Win32 */ GetSystemInfo(&sysinfo); pagesize = sysinfo.dwPageSize; #if (_MSC_VER >= 1800) /* * On VS2103, GetVersionEx is deprecated. Microsoft recommend to * use VerifyVersionInfo instead */ { OSVERSIONINFOEX osvi; DWORDLONG dwlConditionMask = 0; int op = VER_EQUAL; SecureZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); osvi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS; VER_SET_CONDITION(dwlConditionMask, VER_PLATFORMID, op); iswindowsplatform = VerifyVersionInfo(&osvi, VER_PLATFORMID, dwlConditionMask); } #else /* calling GetVersionEx using the OSVERSIONINFO structure. * OSVERSIONINFOEX requires Win NT4 with SP6 or newer NT Versions. * OSVERSIONINFOEX will fail on Win9x and older NT Versions. * See also: * http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp * http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfo_str.asp * http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfoex_str.asp */ { OSVERSIONINFO versinfo; SecureZeroMemory(&versinfo, sizeof(OSVERSIONINFO)); versinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&versinfo); iswindowsplatform = (versinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); } #endif #elif defined(USE_GUARD_PAGES) pagesize = sysconf(_SC_PAGESIZE); if (pagesize == -1) fprintf(stderr, "Warning: call to sysconf() for _SC_PAGESIZE has failed...\n"); #ifdef NEED_DEV_ZERO dev_zero_fd = ws_open("/dev/zero", O_RDWR); g_assert(dev_zero_fd != -1); #endif #endif /* _WIN32 / USE_GUARD_PAGES */ }
void epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data), void (*register_all_handoffs_func)(register_cb cb, gpointer client_data), register_cb cb, gpointer client_data, void (*report_failure)(const char *, va_list), void (*report_open_failure)(const char *, int, gboolean), void (*report_read_failure)(const char *, int), void (*report_write_failure)(const char *, int)) { init_report_err(report_failure, report_open_failure, report_read_failure, report_write_failure); /* initialize memory allocation subsystem */ ep_init_chunk(); se_init_chunk(); /* initialize the GUID to name mapping table */ guids_init(); except_init(); #ifdef HAVE_LIBGNUTLS gnutls_global_init(); #elif defined(HAVE_LIBGCRYPT) gcry_check_version(NULL); #endif tvbuff_init(); tap_init(); prefs_init(); proto_init(register_all_protocols_func, register_all_handoffs_func, cb, client_data); packet_init(); dfilter_init(); final_registration_all_protocols(); host_name_lookup_init(); expert_init(); oids_init(); #ifdef HAVE_LUA_5_1 wslua_init(NULL); #endif #ifdef HAVE_GEOIP geoip_db_init(); #endif }