merge memory allocation fix from RC_0_16
This commit is contained in:
parent
5bf28dd5b2
commit
dcb5cd0e56
|
@ -23,6 +23,10 @@
|
|||
* fix uTP edge case where udp socket buffer fills up
|
||||
* fix nagle implementation in uTP
|
||||
|
||||
* fix memory allocation issue (virtual addres space waste) on windows
|
||||
|
||||
0.16.11 release
|
||||
|
||||
* fix web seed URL double escape issue
|
||||
* fix string encoding issue in alert messages
|
||||
* fix SSL authentication issue
|
||||
|
|
|
@ -44,8 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <unistd.h> // _SC_PAGESIZE
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_MEMALIGN || TORRENT_USE_POSIX_MEMALIGN
|
||||
#include <malloc.h> // memalign
|
||||
#if TORRENT_USE_MEMALIGN || TORRENT_USE_POSIX_MEMALIGN || defined TORRENT_WINDOWS
|
||||
#include <malloc.h> // memalign and _aligned_malloc
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_DEBUG_BUFFERS
|
||||
|
@ -90,6 +90,8 @@ namespace libtorrent
|
|||
|
||||
char* page_aligned_allocator::malloc(size_type bytes)
|
||||
{
|
||||
TORRENT_ASSERT(bytes >= page_size());
|
||||
TORRENT_ASSERT(bytes % page_size() == 0);
|
||||
#ifdef TORRENT_DEBUG_BUFFERS
|
||||
int page = page_size();
|
||||
int num_pages = (bytes + (page-1)) / page + 2;
|
||||
|
@ -115,7 +117,7 @@ namespace libtorrent
|
|||
#elif TORRENT_USE_MEMALIGN
|
||||
return (char*)memalign(page_size(), bytes);
|
||||
#elif defined TORRENT_WINDOWS
|
||||
return (char*)VirtualAlloc(0, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
return (char*)_aligned_malloc(bytes, page_size());
|
||||
#elif defined TORRENT_BEOS
|
||||
void* ret = 0;
|
||||
area_id id = create_area("", &ret, B_ANY_ADDRESS
|
||||
|
@ -149,7 +151,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
VirtualFree(block, 0, MEM_RELEASE);
|
||||
_aligned_free(block);
|
||||
#elif defined TORRENT_BEOS
|
||||
area_id id = area_for(block);
|
||||
if (id < B_OK) return;
|
||||
|
|
Loading…
Reference in New Issue