Bug 1365460 - Replace __DECONST with const_cast. r?njn
--- a/memory/mozjemalloc/mozjemalloc.cpp
+++ b/memory/mozjemalloc/mozjemalloc.cpp
@@ -205,19 +205,16 @@ typedef long ssize_t;
#define MALLOC_DECOMMIT
#endif
#ifndef MOZ_MEMORY_WINDOWS
#ifndef MOZ_MEMORY_SOLARIS
#include <sys/cdefs.h>
#endif
-#ifndef __DECONST
-# define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
-#endif
#include <sys/mman.h>
#ifndef MADV_FREE
# define MADV_FREE MADV_DONTNEED
#endif
#ifndef MAP_NOSYNC
# define MAP_NOSYNC 0
#endif
#include <sys/param.h>
@@ -315,20 +312,16 @@ void *_mmap(void *addr, size_t length, i
#ifdef MOZ_MEMORY_DARWIN
static pthread_key_t tlsIndex;
#endif
#if defined(MOZ_MEMORY_SOLARIS) && defined(MAP_ALIGN) && !defined(JEMALLOC_NEVER_USES_MAP_ALIGN)
#define JEMALLOC_USES_MAP_ALIGN /* Required on Solaris 10. Might improve performance elsewhere. */
#endif
-#ifndef __DECONST
-#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
-#endif
-
#ifdef MOZ_MEMORY_WINDOWS
/* MSVC++ does not support C99 variable-length arrays. */
# define RB_NO_C99_VARARRAYS
#endif
#include "rb.h"
#ifdef MOZ_DEBUG
/* Disable inlining to make debugging easier. */
@@ -3816,17 +3809,17 @@ isalloc(const void *ptr)
} else {
extent_node_t *node, key;
/* Chunk (huge allocation). */
malloc_mutex_lock(&huge_mtx);
/* Extract from tree of huge allocations. */
- key.addr = __DECONST(void *, ptr);
+ key.addr = const_cast<void*>(ptr);
node = extent_tree_ad_search(&huge, &key);
RELEASE_ASSERT(node != NULL);
ret = node->size;
malloc_mutex_unlock(&huge_mtx);
}
@@ -4398,17 +4391,17 @@ huge_ralloc(void *ptr, size_t size, size
if (psize < oldsize) {
extent_node_t *node, key;
pages_decommit((void *)((uintptr_t)ptr + psize),
oldsize - psize);
/* Update recorded size. */
malloc_mutex_lock(&huge_mtx);
- key.addr = __DECONST(void *, ptr);
+ key.addr = const_cast<void*>(ptr);
node = extent_tree_ad_search(&huge, &key);
assert(node != NULL);
assert(node->size == oldsize);
huge_allocated -= oldsize - psize;
/* No need to change huge_mapped, because we didn't
* (un)map anything. */
node->size = psize;
malloc_mutex_unlock(&huge_mtx);
@@ -4423,17 +4416,17 @@ huge_ralloc(void *ptr, size_t size, size
* do need to update the recorded size if the size increased,
* so malloc_usable_size doesn't return a value smaller than
* what was requested via realloc(). */
if (psize > oldsize) {
/* Update recorded size. */
extent_node_t *node, key;
malloc_mutex_lock(&huge_mtx);
- key.addr = __DECONST(void *, ptr);
+ key.addr = const_cast<void*>(ptr);
node = extent_tree_ad_search(&huge, &key);
assert(node != NULL);
assert(node->size == oldsize);
huge_allocated += psize - oldsize;
/* No need to change huge_mapped, because we didn't
* (un)map anything. */
node->size = psize;
malloc_mutex_unlock(&huge_mtx);