From 2bd7db424412a2e221e2b1a4257f8bcb3d2417c2 Mon Sep 17 00:00:00 2001 From: castano Date: Sat, 9 Oct 2010 07:45:48 +0000 Subject: [PATCH] Fix error after changes in Memory.h --- src/nvcore/CMakeLists.txt | 12 +++++++----- src/nvcore/HashMap.h | 2 +- src/nvcore/Memory.h | 24 ++++++++++++++---------- src/nvcore/StrLib.h | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/nvcore/CMakeLists.txt b/src/nvcore/CMakeLists.txt index 63ee1e7..0b9c42a 100644 --- a/src/nvcore/CMakeLists.txt +++ b/src/nvcore/CMakeLists.txt @@ -2,15 +2,14 @@ PROJECT(nvcore) SET(CORE_SRCS nvcore.h - Utils.h - Array.h HashMap.h + Array.h Debug.h Debug.cpp DefsGnucDarwin.h DefsGnucLinux.h DefsGnucWin32.h DefsVcWin32.h FileSystem.h FileSystem.cpp -# FileMonitor.h FileMonitor.cpp + HashMap.h Library.h Library.cpp Memory.h Memory.cpp Ptr.h @@ -20,7 +19,8 @@ SET(CORE_SRCS StdStream.h TextReader.h TextReader.cpp TextWriter.h TextWriter.cpp - Timer.h) + Timer.h + Utils.h) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) @@ -28,7 +28,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ADD_DEFINITIONS(-DNVCORE_EXPORTS) IF(UNIX) - SET(LIBS ${LIBS} ${CMAKE_DL_LIBS}) + SET(LIBS ${LIBS} ${CMAKE_DL_LIBS}) ENDIF(UNIX) IF(NVCORE_SHARED) @@ -44,3 +44,5 @@ INSTALL(TARGETS nvcore RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static) + + diff --git a/src/nvcore/HashMap.h b/src/nvcore/HashMap.h index c9a0baa..ddc8474 100644 --- a/src/nvcore/HashMap.h +++ b/src/nvcore/HashMap.h @@ -503,7 +503,7 @@ namespace nv new_size = nextPowerOfTwo(new_size); HashMap new_hash; - new_hash.table = (Entry *) malloc(sizeof(Entry) * new_size); + new_hash.table = malloc(new_size); nvDebugCheck(new_hash.table != NULL); new_hash.entry_count = 0; diff --git a/src/nvcore/Memory.h b/src/nvcore/Memory.h index 94325cd..8ad3238 100644 --- a/src/nvcore/Memory.h +++ b/src/nvcore/Memory.h @@ -32,17 +32,21 @@ extern "C" { #endif -// C++ helpers. -template T * malloc(size_t count) { - return (T *)::malloc(sizeof(T) * count); -} +namespace nv { -template T * realloc(T * ptr, size_t count) { - return (T *)::realloc(ptr, sizeof(T) * count); -} + // C++ helpers. + template T * malloc(size_t count) { + return (T *)::malloc(sizeof(T) * count); + } -template void free(const T * ptr) { - ::free((T *)ptr); -} + template T * realloc(T * ptr, size_t count) { + return (T *)::realloc(ptr, sizeof(T) * count); + } + + template void free(const T * ptr) { + ::free((T *)ptr); + } + +} // nv namespace #endif // NV_CORE_MEMORY_H diff --git a/src/nvcore/StrLib.h b/src/nvcore/StrLib.h index 8b9de95..8b9fc8e 100644 --- a/src/nvcore/StrLib.h +++ b/src/nvcore/StrLib.h @@ -343,7 +343,7 @@ namespace nv void allocString(const char * str, int len) { - const char * ptr = static_cast(malloc(2 + len + 1)); + const char * ptr = malloc(2 + len + 1); setData( ptr ); setRefCount( 0 );