diff options
| author | DJ Delorie <dj@delorie.com> | 2016-03-17 13:45:05 -0400 |
|---|---|---|
| committer | DJ Delorie <dj@delorie.com> | 2016-03-17 13:45:05 -0400 |
| commit | d6045255ae916be3890780d966fda0d738b635a5 (patch) | |
| tree | 4cb68ca5e7ac4ec914190528d05937cf1bca8de3 /malloc | |
| parent | d35e84028cdade623838130dd4df3d0b22a13446 (diff) | |
| download | glibc-d6045255ae916be3890780d966fda0d738b635a5.tar.xz glibc-d6045255ae916be3890780d966fda0d738b635a5.zip | |
Replace int with size_t as appropriate
Diffstat (limited to 'malloc')
| -rw-r--r-- | malloc/malloc.c | 10 | ||||
| -rw-r--r-- | malloc/mtrace-ctl.c | 16 | ||||
| -rw-r--r-- | malloc/mtrace.h | 8 |
3 files changed, 19 insertions, 15 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index 69d62f6140..e4616ca411 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1085,15 +1085,15 @@ static void free_atfork(void* mem, const void *caller); #include "mtrace.h" volatile __malloc_trace_buffer_ptr __malloc_trace_buffer = NULL; -volatile int __malloc_trace_buffer_size = 0; -volatile int __malloc_trace_buffer_head = 0; +volatile size_t __malloc_trace_buffer_size = 0; +volatile size_t __malloc_trace_buffer_head = 0; static __thread __malloc_trace_buffer_ptr trace_ptr; static void __mtb_trace_entry (uint32_t type, int64_t size, void *ptr1) { - int head1; + size_t head1; head1 = catomic_exchange_and_add (&__malloc_trace_buffer_head, 1); @@ -1115,7 +1115,7 @@ __mtb_trace_entry (uint32_t type, int64_t size, void *ptr1) } int -__malloc_set_trace_buffer (void *bufptr, int bufsize) +__malloc_set_trace_buffer (void *bufptr, size_t bufsize) { __malloc_trace_buffer = 0; __malloc_trace_buffer_size = bufsize / sizeof(struct __malloc_trace_buffer_s); @@ -1125,7 +1125,7 @@ __malloc_set_trace_buffer (void *bufptr, int bufsize) } void * -__malloc_get_trace_buffer (int *bufcount, int *bufhead) +__malloc_get_trace_buffer (size_t *bufcount, size_t *bufhead) { if (bufcount) *bufcount = __malloc_trace_buffer_size; diff --git a/malloc/mtrace-ctl.c b/malloc/mtrace-ctl.c index a253a56288..d972dfcaae 100644 --- a/malloc/mtrace-ctl.c +++ b/malloc/mtrace-ctl.c @@ -29,15 +29,15 @@ void __attribute__((constructor)) djmain() { char *e; - int sz; + size_t sz; e = getenv("MTRACE_CTL_COUNT"); if (!e) e = "1000"; - sz = atoi(e) * sizeof(struct __malloc_trace_buffer_s); + sz = (size_t) atol(e) * sizeof(struct __malloc_trace_buffer_s); char *buf = mmap (NULL, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (!buf) + if (buf == NULL || buf == (char *)(-1)) err("Cannot mmap"); buf[0] = 1; @@ -64,7 +64,7 @@ djend() { char *e; FILE *outf; - int head, size, i; + size_t head, size, i; /* Prevent problems with recursion etc by shutting off trace right away. */ __malloc_trace_buffer_ptr buf = __malloc_get_trace_buffer (&size, &head); @@ -72,14 +72,18 @@ djend() e = getenv("MTRACE_CTL_FILE"); if (!e) - e = "/tmp/mtrace.out"; + { + static char fname[100]; + sprintf(fname, "/tmp/mtrace-%d.out", getpid()); + e = fname; + } outf = fopen(e, "w"); if (!outf) err("cannot open output file"); setbuf (outf, NULL); - fprintf (outf, "%d out of %d events captured\n", head, size); + fprintf (outf, "%ld out of %ld events captured\n", (long)head, (long)size); fprintf (outf, "threadid type path ptr1 size ptr2\n"); for (i=0; i<size; i++) diff --git a/malloc/mtrace.h b/malloc/mtrace.h index a82d317e1a..d6ca8c1255 100644 --- a/malloc/mtrace.h +++ b/malloc/mtrace.h @@ -45,8 +45,8 @@ typedef struct __malloc_trace_buffer_s *__malloc_trace_buffer_ptr; /* These three are only valid inside glibc proper. */ extern volatile __malloc_trace_buffer_ptr __malloc_trace_buffer; -extern volatile int __malloc_trace_buffer_size; -extern volatile int __malloc_trace_buffer_head; +extern volatile size_t __malloc_trace_buffer_size; +extern volatile size_t __malloc_trace_buffer_head; /* bufptr is a random chunk of memory, bufsize is the size of that chunk in BYTES. Returns the size of __malloc_trace_buffer_s. The @@ -54,7 +54,7 @@ extern volatile int __malloc_trace_buffer_head; each record's type is UNUSED (below). The trace buffer may be disabled by passing NULL,0 although it's up to the caller to obtain and free/unmap the previous buffer first. */ -int __malloc_set_trace_buffer (void *bufptr, int bufsize); +int __malloc_set_trace_buffer (void *bufptr, size_t bufsize); /* Returns the location of the buffer (same as passed above, or NULL). Also fills in BUFCOUNT which is the number of records (not bytes) @@ -64,7 +64,7 @@ int __malloc_set_trace_buffer (void *bufptr, int bufsize); had there been size, and the caller must modulo that by BUFCOUNT to get the ending index. The last BUFCOUNT records are stored; earlier records are overwritten. */ -void * __malloc_get_trace_buffer (int *bufcount, int *bufhead); +void * __malloc_get_trace_buffer (size_t *bufcount, size_t *bufhead); #define __MTB_TYPE_UNUSED 0 |
