@node brk, memory @findex brk @subheading Syntax @example #include int brk(void *ptr); @end example @subheading Description This function changes the @emph{break} for the program. This is the first address that, if referenced, will cause a fault to occur. The program asks for more memory by specifying larger values for @var{ptr}. Normally, this is done transparently through the @code{malloc} function. @subheading Return Value Zero if the break was changed, -1 if not. @code{errno} is set to the error. @subheading Portability @portability !ansi, !posix @subheading Example @example if (brk(old_brk+1000)) printf("no memory\n"); @end example @c ---------------------------------------------------------------------- @node sbrk, memory @findex sbrk @subheading Syntax @example #include void *sbrk(int delta) @end example @subheading Description This function changes the "break" of the program by adding @var{delta} to it. This is the highest address that your program can access without causing a violation. Since the heap is the region under the break, you can expand the heap (where @code{malloc} gets memory from) by increasing the break. This function is normally accessed only by @code{malloc} (@pxref{malloc}). @subheading Return Value The address of the first byte outside of the previous valid address range, or -1 if no more memory could be accessed. In other words, a pointer to the chunk of heap you just allocated, if you had passed a positive number. @subheading Portability @portability !ansi, !posix @subheading Example @example char *buf; buf = sbrk(1000); /* allocate space */ @end example @c ---------------------------------------------------------------------- @node _stklen, startup @vindex _stklen @subheading Syntax @example extern int _stklen; @end example @subheading Description This variable sets the minimum stack length that the program requires. Note that the stack may be much larger than this. This value should be set statically, as it is only used at startup. @subheading Portability @portability !ansi, !posix @subheading Example @example int _stklen = 256000; @end example @c ---------------------------------------------------------------------- @node __djgpp_memory_handle_list, memory @vindex __djgpp_memory_handle_list @subheading Syntax @example #include extern __djgpp_sbrk_handle __djgpp_memory_handle_list[256]; @end example @subheading Description This array contains a list of memory handles and program relative offsets allocated by sbrk() in addition to the handle allocated by the stub. These values are normally not needed unless you are doing low-level DPMI page protection or memory mapping. @subheading Portability @portability !ansi, !posix @subheading Example @example #include for(i=0; i<256; i++) @{ int h, a, s; h = __djgpp_memory_handle_list[i].handle; a = __djgpp_memory_handle_list[i].address; s = __djgpp_memory_handle_size[i]; if(a == 0 && i != 0) break; printf("handle[%d]=0x%x base=0x%x size=0x%x\n",i,h,a,s); @} @end example @c ---------------------------------------------------------------------- @node __djgpp_memory_handle_size, memory @vindex __djgpp_memory_handle_size @subheading Syntax @example #include extern unsigned __djgpp_memory_handle_size[256]; @end example @subheading Description This array contains a list of the sizes of the memory regions allocated by sbrk() in addition to the memory region allocated by the stub. These values are normally not needed unless you are dumping the memory blocks. @subheading Portability @portability !ansi, !posix @subheading Example @example #include for(i=0; i<256; i++) @{ int h, a, s; h = __djgpp_memory_handle_list[i].handle; a = __djgpp_memory_handle_list[i].address; s = __djgpp_memory_handle_size[i]; if(a == 0 && i != 0) break; printf("handle[%d]=0x%x base=0x%x size=0x%x\n",i,h,a,s); @} @end example @c ---------------------------------------------------------------------- @node _exit, process @findex _exit @subheading Syntax @example #include void _exit(int exit_code); @end example @subheading Description This function exits the program, returning @var{exit_code} to the calling process. No additional processing (such as closing file descriptors or calls to the static destructor functions) is done, and any @code{atexit} functions are not called; only the hardware interrupt handlers are unhooked, to prevent system crashes e.g. after a call to @code{abort}. This function is normally called only by @code{exit} and @code{abort}. @subheading Return Value This function does not return. @subheading Portability @portability !ansi, !posix @c ---------------------------------------------------------------------- @node __exit, process @findex __exit @subheading Syntax @example #include void __exit(int exit_code); @end example @subheading Description This is an internal library function which exits the program, returning @var{exit_code} to the calling process. No additional processing is done, and any @code{atexit} functions are not called. Since hardware interrupts are not unhooked, this can cause crashes after the program exits. This function is normally called only by @code{_exit}; do @emph{not} call it directly. @subheading Return Value This function does not return. @subheading Portability @portability !ansi, posix