* ----------------------------------------------------------------------------
*/
+/* We use this macro to remove some code that we don't actually want,
+ * rather than to fix its warnings. */
+#define BUILDING_FOR_TOR
+
/*
* Defining MALLOC_EXTRA_SANITY will enable extra checks which are
* related to internal conditions and consistency in malloc.c. This has
extern int __libc_enable_secure;
+#ifndef HAVE_ISSETUGID
static int issetugid(void)
{
if (__libc_enable_secure) return 1;
if (getgid() != getegid()) return 1;
return 0;
}
+#endif
#define PGSHIFT 12
+#undef MADV_FREE
#define MADV_FREE MADV_DONTNEED
#include <pthread.h>
static pthread_mutex_t gen_mutex = PTHREAD_MUTEX_INITIALIZER;
iov[3].iov_len = strlen(p);
iov[4].iov_base = (char*)"\n";
iov[4].iov_len = 1;
- writev(STDERR_FILENO, iov, 5);
+ (void) writev(STDERR_FILENO, iov, 5);
suicide = 1;
#ifdef MALLOC_STATS
iov[3].iov_len = strlen(p);
iov[4].iov_base = (char*)"\n";
iov[4].iov_len = 1;
-
- writev(STDERR_FILENO, iov, 5);
+
+ (void) writev(STDERR_FILENO, iov, 5);
}
#ifdef MALLOC_STATS
for (i = 0; i < 3; i++) {
switch (i) {
case 0:
- j = readlink("/etc/malloc.conf", b, sizeof b - 1);
+ j = (int) readlink("/etc/malloc.conf", b, sizeof b - 1);
if (j <= 0)
continue;
b[j] = '\0';
if (size == 0)
j = 0;
else {
+ size_t ii;
j = 1;
- i = size - 1;
- while (i >>= 1)
+ ii = size - 1;
+ while (ii >>= 1)
j++;
}
return(p);
}
+#ifndef BUILDING_FOR_TOR
static int ispowerof2 (size_t a) {
size_t b;
for (b = 1ULL << (sizeof(size_t)*NBBY - 1); b > 1; b >>= 1)
return 1;
return 0;
}
+#endif
+#ifndef BUILDING_FOR_TOR
int posix_memalign(void **memptr, size_t alignment, size_t size)
{
void *r;
posix_memalign(&r, malloc_pagesize, size);
return r;
}
+#endif
size_t malloc_good_size(size_t size)
{
if (size == 0) {
return 1;
} else if (size <= malloc_maxsize) {
- int i, j;
+ int j;
+ size_t ii;
/* round up to the nearest power of 2, with same approach
* as malloc_bytes() uses. */
j = 1;
- i = size - 1;
- while (i >>= 1)
+ ii = size - 1;
+ while (ii >>= 1)
j++;
return ((size_t)1) << j;
} else {