Fix error after changes in Memory.h

This commit is contained in:
castano 2010-10-09 07:45:48 +00:00
parent 25507428c2
commit 2bd7db4244
4 changed files with 23 additions and 17 deletions

View File

@ -2,15 +2,14 @@ PROJECT(nvcore)
SET(CORE_SRCS SET(CORE_SRCS
nvcore.h nvcore.h
Utils.h Array.h
Array.h HashMap.h
Debug.h Debug.cpp Debug.h Debug.cpp
DefsGnucDarwin.h DefsGnucDarwin.h
DefsGnucLinux.h DefsGnucLinux.h
DefsGnucWin32.h DefsGnucWin32.h
DefsVcWin32.h DefsVcWin32.h
FileSystem.h FileSystem.cpp FileSystem.h FileSystem.cpp
# FileMonitor.h FileMonitor.cpp HashMap.h
Library.h Library.cpp Library.h Library.cpp
Memory.h Memory.cpp Memory.h Memory.cpp
Ptr.h Ptr.h
@ -20,7 +19,8 @@ SET(CORE_SRCS
StdStream.h StdStream.h
TextReader.h TextReader.cpp TextReader.h TextReader.cpp
TextWriter.h TextWriter.cpp TextWriter.h TextWriter.cpp
Timer.h) Timer.h
Utils.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
@ -28,7 +28,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
ADD_DEFINITIONS(-DNVCORE_EXPORTS) ADD_DEFINITIONS(-DNVCORE_EXPORTS)
IF(UNIX) IF(UNIX)
SET(LIBS ${LIBS} ${CMAKE_DL_LIBS}) SET(LIBS ${LIBS} ${CMAKE_DL_LIBS})
ENDIF(UNIX) ENDIF(UNIX)
IF(NVCORE_SHARED) IF(NVCORE_SHARED)
@ -44,3 +44,5 @@ INSTALL(TARGETS nvcore
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static) ARCHIVE DESTINATION lib/static)

View File

@ -503,7 +503,7 @@ namespace nv
new_size = nextPowerOfTwo(new_size); new_size = nextPowerOfTwo(new_size);
HashMap<T, U, H, E> new_hash; HashMap<T, U, H, E> new_hash;
new_hash.table = (Entry *) malloc(sizeof(Entry) * new_size); new_hash.table = malloc<Entry>(new_size);
nvDebugCheck(new_hash.table != NULL); nvDebugCheck(new_hash.table != NULL);
new_hash.entry_count = 0; new_hash.entry_count = 0;

View File

@ -32,17 +32,21 @@ extern "C" {
#endif #endif
// C++ helpers. namespace nv {
template <typename T> T * malloc(size_t count) {
return (T *)::malloc(sizeof(T) * count);
}
template <typename T> T * realloc(T * ptr, size_t count) { // C++ helpers.
return (T *)::realloc(ptr, sizeof(T) * count); template <typename T> T * malloc(size_t count) {
} return (T *)::malloc(sizeof(T) * count);
}
template <typename T> void free(const T * ptr) { template <typename T> T * realloc(T * ptr, size_t count) {
::free((T *)ptr); return (T *)::realloc(ptr, sizeof(T) * count);
} }
template <typename T> void free(const T * ptr) {
::free((T *)ptr);
}
} // nv namespace
#endif // NV_CORE_MEMORY_H #endif // NV_CORE_MEMORY_H

View File

@ -343,7 +343,7 @@ namespace nv
void allocString(const char * str, int len) void allocString(const char * str, int len)
{ {
const char * ptr = static_cast<const char *>(malloc(2 + len + 1)); const char * ptr = malloc<char>(2 + len + 1);
setData( ptr ); setData( ptr );
setRefCount( 0 ); setRefCount( 0 );