Bug 1400096 - Build mozmemory_wrap as C++. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Sep 2017 10:19:37 +0900
changeset 665218 d6874c3d967744d1a2c71638b71bdca08dd3cf93
parent 665199 52c6cc7b1d6e6607a9cc58f2788f9ff748fed264
child 665219 f746c849eb390916ba004df9d5ce702c9532fc2b
push id79976
push userbmo:mh+mozilla@glandium.org
push dateFri, 15 Sep 2017 05:26:57 +0000
reviewersnjn
bugs1400096
milestone57.0a1
Bug 1400096 - Build mozmemory_wrap as C++. r?njn And since the build system doesn't handle transitions from foo.c to foo.cpp properly without a clobber, we work around the issue by switching to unified sources.
memory/build/moz.build
memory/build/mozmemory_wrap.c
memory/build/mozmemory_wrap.cpp
--- a/memory/build/moz.build
+++ b/memory/build/moz.build
@@ -15,19 +15,19 @@ LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = Tru
 DEFINES['MOZ_MEMORY_IMPL'] = True
 
 if CONFIG['MOZ_REPLACE_MALLOC']:
     EXPORTS += [
         'replace_malloc.h',
         'replace_malloc_bridge.h',
     ]
 
-SOURCES += [
+UNIFIED_SOURCES += [
     'mozjemalloc.cpp',
-    'mozmemory_wrap.c',
+    'mozmemory_wrap.cpp',
 ]
 
 if CONFIG['OS_TARGET'] == 'Darwin' and (CONFIG['MOZ_REPLACE_MALLOC'] or
         CONFIG['MOZ_MEMORY']):
     SOURCES += [
         'zone.c',
     ]
 
rename from memory/build/mozmemory_wrap.c
rename to memory/build/mozmemory_wrap.cpp
--- a/memory/build/mozmemory_wrap.c
+++ b/memory/build/mozmemory_wrap.cpp
@@ -109,17 +109,17 @@ vasprintf_impl(char **str, const char *f
 
   ret = vsnprintf(ptr, 128, fmt, ap);
   if (ret < 0) {
     free_impl(ptr);
     *str = NULL;
     return -1;
   }
 
-  _ptr = realloc_impl(ptr, ret + 1);
+  _ptr = reinterpret_cast<char*>(realloc_impl(ptr, ret + 1));
   if (_ptr == NULL) {
     free_impl(ptr);
     *str = NULL;
     return -1;
   }
 
   *str = _ptr;