This file was deleted.

This file was deleted.

@@ -185,7 +185,8 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker {
// for the purposes of heap leak checking.
// If 'ptr' does not point to an active allocated object
// at the time of this call, it is ignored;
// but if it does, the object must not get deleted from the heap later on.
// but if it does, the object must not get deleted from the heap later on;
// it must also be not already ignored at the time of this call.
//
// See also HiddenPointer, below, if you need to prevent a pointer from
// being traversed by the heap checker but do not wish to transitively

This file was deleted.

@@ -49,8 +49,11 @@
#ifndef _MSC_VER
#include <stdint.h>
#endif
#include <string>
#include <vector>
#define NO_STL
#ifndef NO_STL
#include <string>
#include <vector>
#endif

// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef PERFTOOLS_DLL_DECL
@@ -63,26 +66,22 @@

static const int kMallocHistogramSize = 64;

// One day, we could support other types of writers (perhaps for C?)
typedef std::string MallocExtensionWriter;
#ifndef NO_STL
typedef std::string MallocExtensionWriter;
#else
// One day, we could support other types of writers (perhaps for C?)
class DummyString
{
public:
void append(const char *c, size_t size){}
};
typedef DummyString MallocExtensionWriter;
#endif

namespace base {
struct MallocRange;
}

// Interface to a pluggable system allocator.
class SysAllocator {
public:
SysAllocator() {
}
virtual ~SysAllocator();

// Allocates "size"-byte of memory from system aligned with "alignment".
// Returns NULL if failed. Otherwise, the returned pointer p up to and
// including (p + actual_size -1) have been allocated.
virtual void* Alloc(size_t size, size_t *actual_size, size_t alignment) = 0;
};

// The default implementations of the following routines do nothing.
// All implementations should be thread-safe; the current one
// (TCMallocImplementation) is.
@@ -100,7 +99,6 @@ class PERFTOOLS_DLL_DECL MallocExtension {

// See "verify_memory.h" to see what these routines do
virtual bool VerifyAllMemory();
// TODO(csilvers): change these to const void*.
virtual bool VerifyNewMemory(void* p);
virtual bool VerifyArrayNewMemory(void* p);
virtual bool VerifyMallocMemory(void* p);
@@ -116,9 +114,7 @@ class PERFTOOLS_DLL_DECL MallocExtension {
// Outputs to "writer" a sample of live objects and the stack traces
// that allocated these objects. The format of the returned output
// is equivalent to the output of the heap profiler and can
// therefore be passed to "pprof". This function is equivalent to
// ReadStackTraces. The main difference is that this function returns
// serialized data appropriately formatted for use by the pprof tool.
// therefore be passed to "pprof".
// NOTE: by default, tcmalloc does not do any heap sampling, and this
// function will always return an empty sample. To get useful
// data from GetHeapSample, you must also set the environment
@@ -128,10 +124,7 @@ class PERFTOOLS_DLL_DECL MallocExtension {
// Outputs to "writer" the stack traces that caused growth in the
// address space size. The format of the returned output is
// equivalent to the output of the heap profiler and can therefore
// be passed to "pprof". This function is equivalent to
// ReadHeapGrowthStackTraces. The main difference is that this function
// returns serialized data appropriately formatted for use by the
// pprof tool. (This does not depend on, or require,
// be passed to "pprof". (This does not depend on, or require,
// TCMALLOC_SAMPLE_PARAMETER.)
virtual void GetHeapGrowthStacks(MallocExtensionWriter* writer);

@@ -220,27 +213,6 @@ class PERFTOOLS_DLL_DECL MallocExtension {
// Most malloc implementations ignore this routine.
virtual void MarkThreadBusy();

// Gets the system allocator used by the malloc extension instance. Returns
// NULL for malloc implementations that do not support pluggable system
// allocators.
virtual SysAllocator* GetSystemAllocator();

// Sets the system allocator to the specified.
//
// Users could register their own system allocators for malloc implementation
// that supports pluggable system allocators, such as TCMalloc, by doing:
// alloc = new MyOwnSysAllocator();
// MallocExtension::instance()->SetSystemAllocator(alloc);
// It's up to users whether to fall back (recommended) to the default
// system allocator (use GetSystemAllocator() above) or not. The caller is
// responsible to any necessary locking.
// See tcmalloc/system-alloc.h for the interface and
// tcmalloc/memfs_malloc.cc for the examples.
//
// It's a no-op for malloc implementations that do not support pluggable
// system allocators.
virtual void SetSystemAllocator(SysAllocator *a);

// Try to release num_bytes of free memory back to the operating
// system for reuse. Use this extension with caution -- to get this
// memory back may require faulting pages back in by the OS, and
@@ -281,27 +253,8 @@ class PERFTOOLS_DLL_DECL MallocExtension {
// will return 0.)
// This is equivalent to malloc_size() in OS X, malloc_usable_size()
// in glibc, and _msize() for windows.
// TODO(csilvers): change to const void*.
virtual size_t GetAllocatedSize(void* p);

// Returns kOwned if this malloc implementation allocated the memory
// pointed to by p, or kNotOwned if some other malloc implementation
// allocated it or p is NULL. May also return kUnknownOwnership if
// the malloc implementation does not keep track of ownership.
// REQUIRES: p must be a value returned from a previous call to
// malloc(), calloc(), realloc(), memalign(), posix_memalign(),
// valloc(), pvalloc(), new, or new[], and must refer to memory that
// is currently allocated (so, for instance, you should not pass in
// a pointer after having called free() on it).
enum Ownership {
// NOTE: Enum values MUST be kept in sync with the version in
// malloc_extension_c.h
kUnknownOwnership = 0,
kOwned,
kNotOwned
};
virtual Ownership GetOwnership(const void* p);

// The current malloc implementation. Always non-NULL.
static MallocExtension* instance();

@@ -346,8 +299,11 @@ class PERFTOOLS_DLL_DECL MallocExtension {
// and not returned to tcmalloc.
//
// "tcmalloc.thread" - tcmalloc's per-thread caches. Never unmapped.
#ifndef NO_STL
virtual void GetFreeListSizes(std::vector<FreeListInfo>* v);
#endif

protected:
// Get a list of stack traces of sampled allocation points. Returns
// a pointer to a "new[]-ed" result array, and stores the sample
// period in "sample_period".

This file was deleted.

This file was deleted.

This file was deleted.

@@ -157,7 +157,7 @@ struct ProfilerState {
int enabled; /* Is profiling currently enabled? */
time_t start_time; /* If enabled, when was profiling started? */
char profile_name[1024]; /* Name of profile file being written, or '\0' */
int samples_gathered; /* Number of samples gathered so far (or 0) */
int samples_gathered; /* Number of samples gatheered to far (or 0) */
};
PERFTOOLS_DLL_DECL void ProfilerGetCurrentState(struct ProfilerState* state);

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -31,18 +31,14 @@
// Sanjay Ghemawat <opensource@google.com>

#include <config.h>
#include "internal_logging.h"
#include <stdarg.h> // for va_end, va_start
#include <stdio.h> // for vsnprintf, va_list, etc
#include <stdlib.h> // for abort
#include <string.h> // for strlen, memcpy
#include <stdio.h>
#include <stdarg.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> // for write()
#endif

#include <string.h>
#include <google/malloc_extension.h>
#include "base/logging.h" // for perftools_vsnprintf
#include "base/spinlock.h" // for SpinLockHolder, SpinLock
#include "internal_logging.h"

static const int kLogBufSize = 800;

@@ -54,10 +50,12 @@ void TCMalloc_MESSAGE(const char* filename,
if (n < kLogBufSize) {
va_list ap;
va_start(ap, format);
perftools_vsnprintf(buf + n, kLogBufSize - n, format, ap);
vsnprintf(buf + n, kLogBufSize - n, format, ap);
va_end(ap);
}
write(STDERR_FILENO, buf, strlen(buf));
OutputDebugString(buf);
OutputDebugString("\n");
}

static const int kStatsBufferSize = 16 << 10;
@@ -68,16 +66,17 @@ static void TCMalloc_CRASH_internal(bool dump_stats,
int line_number,
const char* format, va_list ap) {
char buf[kLogBufSize];
const int n = snprintf(buf, sizeof(buf), "%s:%d] ", filename, line_number);
const int n = snprintf(buf, sizeof(buf), "%s(%d): ", filename, line_number);
if (n < kLogBufSize) {
perftools_vsnprintf(buf + n, kLogBufSize - n, format, ap);
vsnprintf(buf + n, kLogBufSize - n, format, ap);
}
write(STDERR_FILENO, buf, strlen(buf));
if (dump_stats) {
MallocExtension::instance()->GetStats(stats_buffer, kStatsBufferSize);
write(STDERR_FILENO, stats_buffer, strlen(stats_buffer));
}

OutputDebugString(buf);
//OutputDebugString("\n");
abort();
}

@@ -103,7 +102,7 @@ void TCMalloc_Printer::printf(const char* format, ...) {
if (left_ > 0) {
va_list ap;
va_start(ap, format);
const int r = perftools_vsnprintf(buf_, left_, format, ap);
const int r = vsnprintf(buf_, left_, format, ap);
va_end(ap);
if (r < 0) {
// Perhaps an old glibc that returns -1 on truncation?
@@ -36,7 +36,10 @@
#define TCMALLOC_INTERNAL_LOGGING_H_

#include <config.h>
#include <stddef.h> // for size_t
#include <stdlib.h> // for abort()
#ifdef HAVE_UNISTD_H
#include <unistd.h> // for write()
#endif

//-------------------------------------------------------------------
// Utility routines

This file was deleted.

This file was deleted.

This file was deleted.