/* sbrk */ #if defined(SYS_sbrk) extern void * _sbrk(intptr_t increment); /* XXX in-kernel prototype */ # if defined(SYS_brk) /* SYS_sbrk && SYS_brk */ extern int _brk(void * addr); /* XXX in-kernel prototype */ void * sbrk(intptr_t increment) /* _brk is used to actually allocate memory */ { void * cur; if((cur = _sbrk(0)) == (void*)-1 || increment == 0) return cur; return _brk(cur + increment) != (void*)-1 ? cur : (void*)-1; }
int brk(void *end_data_seg) { if (! end_data_seg) return -1; kernel_heap_top = _brk(end_data_seg); return 0; }
arg_t _sbrk(void) { uaddr_t oldbrk; udata.u_argn += (oldbrk = udata.u_break); if (_brk()) /* brk (udata.u_argn) */ return (-1); return ((unsigned) oldbrk); }
int brk(void *end_data_segment) { if (__init_brk() == 0) { __curbrk = (void *) _brk(end_data_segment); if (__curbrk == end_data_segment) return(0); errno = ENOMEM; } return(-1); }
int __init_brk (void) { if (__curbrk == 0) { __curbrk = (void *) _brk(0); if (__curbrk == (void *) 0) { errno = ENOMEM; return -1; } } return 0; }
void * malloc (size_t size) { void * retval; if (size <= 0) return NULL; /* Align on a 4B boundary */ size = ((size-1) & ~3) + 4; if (! kernel_heap_top) kernel_heap_top = _brk(0); if (! malloc_heap_top) malloc_heap_top = kernel_heap_top; retval = malloc_heap_top; malloc_heap_top += size; _brk(malloc_heap_top); return retval; }
void * sbrk(intptr_t increment) { static void * cur = &end; void * ptr; if(increment == 0) return cur; if(_brk(cur + increment) == -1) return (void*)-1; ptr = cur; cur += increment; return ptr; }
int brk(void *addr) { void *newbrk; if (curbrk == addr) return 0; newbrk = _brk(addr); curbrk = newbrk; if (newbrk < addr) { errno = ENOMEM; return -1; } return 0; }
void * sbrk(intptr_t increment) { if (__init_brk () == 0) { char * tmp = (char*)__curbrk+increment; __curbrk = _brk(tmp); if (__curbrk == tmp) return tmp-increment; __set_errno(ENOMEM); return ((void *) -1); } return ((void *) -1); }
int __init_brk (void) { if (___brk_addr == 0) { ___brk_addr = _brk(0); if (___brk_addr == 0) { __set_errno(ENOMEM); return -1; } } return 0; }
int __init_brk (void) { if (__curbrk == 0) { __curbrk = _brk(0); if (__curbrk == 0) { __set_errno(ENOMEM); return -1; } } return 0; }
void * _malloc(struct chunk * _chunk, size_t size){ void * ret = 0; size_t newsize = sizeof(struct chunk*) + sizeof(size_t) + size; struct chunk ** tmp = (struct chunk **)_brk(_chunk, newsize); if (tmp != 0){ *tmp = _chunk; size_t * _size = (size_t*)++tmp; *_size = size; ret = (void*)++_size; _chunk->count++; } return ret; }
XN_C_API XnStatus xnOSWaitEvent(const XN_EVENT_HANDLE EventHandle, XnUInt32 nMilliseconds) { XN_VALIDATE_INPUT_PTR(EventHandle); if (!EventHandle->bOn) { // problem: this is a non-threaded environment, so the event will never be set! _brk(); return XN_STATUS_ERROR; } if (!EventHandle->bManual) { // reset EventHandle->bOn = FALSE; } // All is good... return (XN_STATUS_OK); }
void * _realloc(void * mem, size_t size){ void * ret = 0; struct chunk * _chunk = (struct chunk *)((char*)mem - sizeof(size_t) - sizeof(struct chunk)); if (_chunk->flag != _flag){ abort(); } size_t oldsize = *(size_t *)((char*)mem - sizeof(size_t)); if (oldsize >= size){ return mem; } size_t increment = size - oldsize; if (increment < (_chunk->size - _chunk->slide)){ _brk(_chunk, increment); ret = mem; } return ret; }
int brk(void * addr) { return _brk(addr); }
/* brk */ #if defined(SYS_brk) extern int _brk(void * addr); /* XXX in-kernel prototype */ int brk(void * addr) { return _brk(addr) != -1 ? 0 : -1; }
int FTP::ExpandList(PluginPanelItem *pi,int icn,FP_SizeItemList* il,BOOL FromPlugin,ExpandListCB cb,LPVOID Param) { PROC(("ExpandList","cn:%d, ilcn:%d/%d, %s, cb:%08X",icn,il ? il->Count() : 0,il ? il->MaxCount : 0,FromPlugin?"PLUGIN":"LOCAL",cb)) BOOL pSaved = Host.Home[0] && SelectFile.Length(); BOOL old_ext = hConnect ? hConnect->Host.ExtCmdView : FALSE; FTPCurrentStates olds = CurrentState; int rc; { FTPConnectionBreakable _brk(hConnect,FALSE); CurrentState = fcsExpandList; if(hConnect) { hConnect->Host.ExtCmdView = FALSE; hConnect->CurrentState = fcsExpandList; } if(!pSaved) SaveUsedDirNFile(); rc = ExpandListINT(pi,icn,il,FromPlugin,cb,Param); if(hConnect) { hConnect->Host.ExtCmdView = old_ext; hConnect->CurrentState = olds; } CurrentState = olds; } Log(("ExpandList rc=%d",rc)); #if defined(__FILELOG__) if(rc) { Log(("Expand succ ends containing:")); if(il) LogPanelItems(il->Items(), il->Count()); else Log(("Files list does not contains files")); } #endif if(!pSaved) { if(!rc) { SaveLastError _err; if(Host.Home[0]) { char str[MAX_PATH]; GetCurPath(str, ARRAYSIZE(str)); if(StrCmpI(str, Host.Home) != 0) SetDirectory(Host.Home,FP_LastOpMode); } } else { SelectFile = ""; Host.Home[0] = 0; } } return rc; }