OLD | NEW |
1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 return SpanToMallocResult(span); | 1383 return SpanToMallocResult(span); |
1384 } | 1384 } |
1385 | 1385 |
1386 // Helpers for use by exported routines below: | 1386 // Helpers for use by exported routines below: |
1387 | 1387 |
1388 inline void do_malloc_stats() { | 1388 inline void do_malloc_stats() { |
1389 PrintStats(1); | 1389 PrintStats(1); |
1390 } | 1390 } |
1391 | 1391 |
1392 inline int do_mallopt(int cmd, int value) { | 1392 inline int do_mallopt(int cmd, int value) { |
1393 return 1; // Indicates error | 1393 if (cmd == TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC) |
| 1394 return TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC; |
| 1395 |
| 1396 // 1 is the success return value according to man mallopt(). However (see the |
| 1397 // BUGS section in the manpage), most implementations return always 1. |
| 1398 // This code is just complying with that (buggy) expectation. |
| 1399 return 1; |
1394 } | 1400 } |
1395 | 1401 |
1396 #ifdef HAVE_STRUCT_MALLINFO | 1402 #ifdef HAVE_STRUCT_MALLINFO |
1397 inline struct mallinfo do_mallinfo() { | 1403 inline struct mallinfo do_mallinfo() { |
1398 TCMallocStats stats; | 1404 TCMallocStats stats; |
1399 ExtractStats(&stats, NULL, NULL, NULL); | 1405 ExtractStats(&stats, NULL, NULL, NULL); |
1400 | 1406 |
1401 // Just some of the fields are filled in. | 1407 // Just some of the fields are filled in. |
1402 struct mallinfo info; | 1408 struct mallinfo info; |
1403 memset(&info, 0, sizeof(info)); | 1409 memset(&info, 0, sizeof(info)); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 *mark = ~allocated_mark; // Distinctively not allocated. | 1902 *mark = ~allocated_mark; // Distinctively not allocated. |
1897 } | 1903 } |
1898 | 1904 |
1899 static void MarkAllocatedRegion(void* ptr) { | 1905 static void MarkAllocatedRegion(void* ptr) { |
1900 if (ptr == NULL) return; | 1906 if (ptr == NULL) return; |
1901 MarkType* mark = GetMarkLocation(ptr); | 1907 MarkType* mark = GetMarkLocation(ptr); |
1902 *mark = GetMarkValue(ptr, mark); | 1908 *mark = GetMarkValue(ptr, mark); |
1903 } | 1909 } |
1904 | 1910 |
1905 #endif // TCMALLOC_VALIDATION | 1911 #endif // TCMALLOC_VALIDATION |
OLD | NEW |