aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-07-06 18:33:35 +0000
committerNick Mathewson <nickm@torproject.org>2008-07-06 18:33:35 +0000
commit1a564901e41adc0e3b6dc9c5beb0dd4fec734331 (patch)
treea39aaaf26956a7051c25d7fb49de6ec2786fed32
parentf302f23270d53a4b0cd8fd934b94bd9b6e37e98c (diff)
downloadtor-1a564901e41adc0e3b6dc9c5beb0dd4fec734331.tar
tor-1a564901e41adc0e3b6dc9c5beb0dd4fec734331.tar.gz
Fix the rest of the GCC warnings on OpenBSD_malloc_linux.c
svn:r15698
-rw-r--r--src/common/OpenBSD_malloc_Linux.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/common/OpenBSD_malloc_Linux.c b/src/common/OpenBSD_malloc_Linux.c
index 480fcba16..19dac7765 100644
--- a/src/common/OpenBSD_malloc_Linux.c
+++ b/src/common/OpenBSD_malloc_Linux.c
@@ -123,7 +123,7 @@ struct pginfo {
};
/* How many bits per u_long in the bitmap */
-#define MALLOC_BITS (NBBY * sizeof(u_long))
+#define MALLOC_BITS (int)((NBBY * sizeof(u_long)))
/*
* This structure describes a number of free pages.
@@ -514,16 +514,17 @@ malloc_exit(void)
static void *MMAP_A(size_t pages, size_t alignment)
{
- void *j;
- if (pages%malloc_pagesize != 0)
- pages = pages - pages%malloc_pagesize + malloc_pagesize;
- size_t first_size = pages + alignment - malloc_pagesize;
- void *p = MMAP(first_size);
- size_t rest = ((size_t)p) % alignment;
+ void *j, *p;
+ size_t first_size, rest, begin, end;
+ if (pages%malloc_pagesize != 0)
+ pages = pages - pages%malloc_pagesize + malloc_pagesize;
+ first_size = pages + alignment - malloc_pagesize;
+ p = MMAP(first_size);
+ rest = ((size_t)p) % alignment;
j = (rest == 0) ? p : (void*) ((size_t)p + alignment - rest);
- size_t begin = (size_t)j - (size_t)p;
+ begin = (size_t)j - (size_t)p;
if (begin != 0) munmap(p, begin);
- size_t end = (size_t)p + first_size - ((size_t)j + pages);
+ end = (size_t)p + first_size - ((size_t)j + pages);
if(end != 0) munmap( (void*) ((size_t)j + pages), end);
return j;
@@ -830,7 +831,7 @@ static void *
malloc_pages(size_t size)
{
void *p, *delay_free = NULL, *tp;
- int i;
+ size_t i;
struct pginfo **pd;
struct pdinfo *pi;
u_long pidx, index;
@@ -962,6 +963,7 @@ malloc_pages(size_t size)
}
pd = pi->base;
pd[PI_OFF(index)] = MALLOC_FIRST;
+
for (i = 1; i < size; i++) {
if (!PI_OFF(index + i)) {
pidx++;
@@ -992,6 +994,7 @@ malloc_pages(size_t size)
}
pd[PI_OFF(index + i)] = MALLOC_FIRST;
}
+
malloc_used += size << malloc_pageshift;
malloc_guarded += malloc_guard;