Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(831)

Side by Side Diff: nspr/pr/src/misc/prsystem.c

Issue 279293002: [Mac] Release the mach_host_self() Mach port when done with it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public 2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 5
6 #include "primpl.h" 6 #include "primpl.h"
7 #include "prsystem.h" 7 #include "prsystem.h"
8 #include "prprf.h" 8 #include "prprf.h"
9 #include "prlong.h" 9 #include "prlong.h"
10 10
(...skipping 15 matching lines...) Expand all
26 #if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \ 26 #if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \
27 || defined(OPENBSD) || defined(DARWIN) 27 || defined(OPENBSD) || defined(DARWIN)
28 #define _PR_HAVE_SYSCTL 28 #define _PR_HAVE_SYSCTL
29 #include <sys/param.h> 29 #include <sys/param.h>
30 #include <sys/sysctl.h> 30 #include <sys/sysctl.h>
31 #endif 31 #endif
32 32
33 #if defined(DARWIN) 33 #if defined(DARWIN)
34 #include <mach/mach_init.h> 34 #include <mach/mach_init.h>
35 #include <mach/mach_host.h> 35 #include <mach/mach_host.h>
36 #include <mach/mach_port.h>
36 #endif 37 #endif
37 38
38 #if defined(HPUX) 39 #if defined(HPUX)
39 #include <sys/mpctl.h> 40 #include <sys/mpctl.h>
40 #include <sys/pstat.h> 41 #include <sys/pstat.h>
41 #endif 42 #endif
42 43
43 #if defined(XP_UNIX) 44 #if defined(XP_UNIX)
44 #include <unistd.h> 45 #include <unistd.h>
45 #include <sys/utsname.h> 46 #include <sys/utsname.h>
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 #elif defined(HPUX) 292 #elif defined(HPUX)
292 293
293 struct pst_static info; 294 struct pst_static info;
294 int result = pstat_getstatic(&info, sizeof(info), 1, 0); 295 int result = pstat_getstatic(&info, sizeof(info), 1, 0);
295 if (result == 1) 296 if (result == 1)
296 bytes = (PRUint64) info.physical_memory * info.page_size; 297 bytes = (PRUint64) info.physical_memory * info.page_size;
297 298
298 #elif defined(DARWIN) 299 #elif defined(DARWIN)
299 300
301 mach_port_t mach_host = mach_host_self();
302
300 struct host_basic_info hInfo; 303 struct host_basic_info hInfo;
301 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; 304 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
302 305
303 int result = host_info(mach_host_self(), 306 int result = host_info(mach_host,
304 HOST_BASIC_INFO, 307 HOST_BASIC_INFO,
305 (host_info_t) &hInfo, 308 (host_info_t) &hInfo,
306 &count); 309 &count);
310 mach_port_deallocate(mach_task_self(), mach_host);
307 if (result == KERN_SUCCESS) 311 if (result == KERN_SUCCESS)
308 bytes = hInfo.max_mem; 312 bytes = hInfo.max_mem;
309 313
310 #elif defined(WIN32) 314 #elif defined(WIN32)
311 315
312 MEMORYSTATUSEX memStat; 316 MEMORYSTATUSEX memStat;
313 memStat.dwLength = sizeof(memStat); 317 memStat.dwLength = sizeof(memStat);
314 if (GlobalMemoryStatusEx(&memStat)) 318 if (GlobalMemoryStatusEx(&memStat))
315 bytes = memStat.ullTotalPhys; 319 bytes = memStat.ullTotalPhys;
316 320
(...skipping 19 matching lines...) Expand all
336 } 340 }
337 341
338 #else 342 #else
339 343
340 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); 344 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
341 345
342 #endif 346 #endif
343 347
344 return bytes; 348 return bytes;
345 } /* end PR_GetPhysicalMemorySize() */ 349 } /* end PR_GetPhysicalMemorySize() */
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698