This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch dj/malloc updated. glibc-2.22-722-gd604525
- From: dj at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 17 Mar 2016 20:04:57 -0000
- Subject: GNU C Library master sources branch dj/malloc updated. glibc-2.22-722-gd604525
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, dj/malloc has been updated
via d6045255ae916be3890780d966fda0d738b635a5 (commit)
from d35e84028cdade623838130dd4df3d0b22a13446 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d6045255ae916be3890780d966fda0d738b635a5
commit d6045255ae916be3890780d966fda0d738b635a5
Author: DJ Delorie <dj@delorie.com>
Date: Thu Mar 17 13:45:05 2016 -0400
Replace int with size_t as appropriate
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 69d62f6..e4616ca 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 a253a56..d972dfc 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 a82d317..d6ca8c1 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
-----------------------------------------------------------------------
Summary of changes:
malloc/malloc.c | 10 +++++-----
malloc/mtrace-ctl.c | 16 ++++++++++------
malloc/mtrace.h | 8 ++++----
3 files changed, 19 insertions(+), 15 deletions(-)
hooks/post-receive
--
GNU C Library master sources