= n_elem * item_size;
105 #ifdef USE_SETHEAPLIMIT 106 static size_ts_SetHeapLimit_Curr = 0;
107 static size_ts_SetHeapLimit_Add = 0;
108 static size_ts_SetHeapLimit_Max = 0;
109 staticTNlmMutex s_SetHeapLimit_Mutex;
116 if(NlmMutexLockEx(&s_SetHeapLimit_Mutex) != 0)
121rl.rlim_max = RLIM_INFINITY;
124rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
127 if(setrlimit(RLIMIT_DATA, &rl) == 0) {
128s_SetHeapLimit_Curr = curr;
129s_SetHeapLimit_Add = add;
130s_SetHeapLimit_Max =
max;
134NlmMutexUnlock(s_SetHeapLimit_Mutex);
183 switch( allocator ) {
207 #ifdef USE_SETHEAPLIMIT 208 if(!x_ptr && s_SetHeapLimit_Curr) {
209NlmMutexLock(s_SetHeapLimit_Mutex);
211 while(s_SetHeapLimit_Curr < s_SetHeapLimit_Max) {
213 size_tx_curr = s_SetHeapLimit_Curr + s_SetHeapLimit_Add;
214 if(x_curr > s_SetHeapLimit_Max)
215x_curr = s_SetHeapLimit_Max;
219 "Trying to allocate %ld bytes; " 220 "adjusting max.avail. heap size from %ld to %ld",
221(
long)
size, (
long)s_SetHeapLimit_Curr, (
long)x_curr);
224rl.rlim_cur = x_curr;
225rl.rlim_max = RLIM_INFINITY;
226 if(setrlimit(RLIMIT_DATA, &rl) != 0)
229s_SetHeapLimit_Curr = x_curr;
231 switch( allocator ) {
246NlmMutexUnlock(s_SetHeapLimit_Mutex);
252memset(x_ptr, 0,
size);
259 "Failed to allocate %ld bytes", (
long)
size);
284 if(x_ptr &&
size> oldsize)
285memset((
char*)x_ptr + oldsize, 0,
size- oldsize);
307 #if defined(_DEBUG) && defined(OS_MSWIN) 309 const char*filename,
intlinenum)
315 "MemFree: attempt to free invalid pointer");
367 char*dest = (
char*) dst;
368 const char*sorc = (
const char*) src;
373 while(bytes-- != 0) {
377 while(bytes-- != 0) {
405 const void* what,
size_twhat_size)
407 size_t i, rbound, pos;
409rbound = where_size - what_size;
412 if(where_size && what_size && where_size >= what_size) {
413 while((
i<= rbound) && (pos == (size_t)-1)) {
414 if(memcmp((
char*)where +
i, what, what_size)==0)
425 #if defined(OS_MAC) || defined(OS_UNIX_DARWIN) || defined(OS_MSWIN) || defined(MSC_VIRT) 429 static char* _msgNullHnd =
"NULL handle passed as an argument";
451 #if defined(OS_MAC) || defined(OS_UNIX_DARWIN) 474 else if(clear_out) {
476wrote_to_handle =
TRUE;
527 #if defined(OS_MAC) || defined(OS_UNIX_DARWIN) 530 if(MemError() != noErr)
537hnd2 = (
Nlm_Handle) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, hnd,
size);
547hnd2 = (
Nlm_Handle) _vrealloc ((_vmhnd_t)hnd, (
unsignedlong)
size);
571 #if defined(OS_MAC) || defined(OS_UNIX_DARWIN) 572DisposeHandle ((
Handle) hnd);
578HeapFree(GetProcessHeap(), 0, (
HANDLE) hnd);
580GlobalFree ((
HANDLE) hnd);
590_vunlock(x, _VM_CLEAN);
616 #if defined(OS_MAC) || defined(OS_UNIX_DARWIN) 626ptr = GlobalLock ((
HANDLE) hnd);
634ptr = _vlock((_vmhnd_t) hnd);
649 intdirty = _VM_CLEAN;
655 #if defined(OS_MAC) || defined(OS_UNIX_DARWIN) 664GlobalUnlock ((
HANDLE) hnd);
672 if(wrote_to_handle ==
TRUE)
674_vunlock ((_vmhnd_t) hnd, dirty);
675wrote_to_handle =
FALSE;
705 if(bytes >0 && (hMem = GlobalAlloc(GMEM_DDESHARE,bytes)))
707 if(pMem = GlobalLock(hMem))
713TRACE(
"dll_Malloc(%ld) failed\n",bytes);
719HGLOBAL hMem = GlobalHandle(pMem);
734 #if defined(MMAP_AVAIL) || defined(WIN32) 750 if((mem_mapp->
file_size= NCBI_NS_NCBI::CFile(name).GetLength()) < 0)
758 charx_name[MAX_PATH], *
str;
764 if( !(mem_mapp->hMap =
769OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
773mem_mapp->hMap = CreateFileMapping(hFile,
NULL, PAGE_READONLY,
775CloseHandle( hFile );
776 if( !mem_mapp->hMap )
781MapViewOfFile(mem_mapp->hMap, FILE_MAP_READ,
783CloseHandle( mem_mapp->hMap );
788 #elif defined(MMAP_AVAIL) 790 intfd = open(name, O_RDONLY);
795PROT_READ, MAP_PRIVATE, fd, 0);
797 if((
void*) mem_mapp->
mmp_begin== (
void*) MAP_FAILED)
819 if( mem_mapp->hMap )
820CloseHandle( mem_mapp->hMap );
821 #elif defined(MMAP_AVAIL) 831 #if defined(HAVE_MADVISE) && defined(MADV_NORMAL) 838adv = MADV_RANDOM;
break;
840adv = MADV_SEQUENTIAL;
break;
842adv = MADV_WILLNEED;
break;
844adv = MADV_DONTNEED;
break;
849 returnmadvise((
char*)
addr,
len, adv) == 0;
858 #if defined(HAVE_MADVISE) && defined(MADV_NORMAL)The NCBI C++ standard methods for dealing with std::string.
BEGIN_CTRANSITION_SCOPE short g_bBadPtr
void Nlm_SetMemFailFlag(Nlm_Boolean val)
static Nlm_Boolean post_mssg_for_mem_fail
static void * s_MemAllocator(void *ptr, size_t size, unsigned int flags, EAllocator allocator)
static const char * _msgMemory
NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_StringNCpy_0(char FAR *to, const char FAR *from, size_t max)
static const char * str(char *buf, int n)
#define INVALID_HANDLE_VALUE
A value for an invalid file handle.
#define HANDLE
An abstraction for a file handle.
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
#define TRUE
bool replacment for C indicating true.
#define FALSE
bool replacment for C indicating false.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4