I read <Windows via C / C ++ 5th edition> and the following is a quote:
Each virtual address space of the process is divided into sections. On x86 32-bit Windows, partition 0x00000000 - The 0x0000FFFF (inclusive) destination section of the NULL pointer is invoked. This section is intended to help programmers catch a NULL pointer job. If the stream in your aprocess is trying to read or write to the memory address in this partition, access to the cello is raised.
I am wondering why we should use the address space range instead of just the value 0 to catch the assignment of a NULL pointer? AFAIK, NULL is 0. So, what about this design? Is there anything else in this range that the user should not touch? Or is NULL not necessarily 0?
Many thanks.
- , . 0- 4 ( , 0-15- ( 64 )) , 0 ( 0x00000FFF 0x0000FFFF, ) .
-. 0, () 1, - VM , . , "" VM. , - .
(, , , , , 0- .)
, Windows (post Win98) 64 KB 4 ? Wyzard , .
* : RE: 64 ? - -, Windows Core, , , , 64 , Windows 64 . ? , , , : http://blogs.msdn.com/b/oldnewthing/archive/2003/10/03/55239.aspx. . *
C ++ NULL 0, 0 . , Windows , - .
, , , myarray[n], myarray null, mystruct->myfield, mystruct null. , , - .
myarray[n]
myarray
mystruct->myfield
mystruct
, , null . :
int startOffset = 1000; //start at 1000th element; char* buffer = obtain();// happens to be null for( int i = startOffset; buffer[i] != 0; i++ ) { //do stuff }
, . , buffer , , , "".
buffer
, , , .
struct Foo { int a; inb b; }* Bar = 0; Bar->b = 0;
In int = 32bit compilers, member 'b' will contain 4 bytes in the structure, so Bar-> b will try to access address 0x00000004.
Source: https://habr.com/ru/post/1776153/More articles:Is there a way to omit a variable from a superclass? - javaYou need to use a random number generator in the form of an object type type, but you do not need the burden of its dependence - javaClojure: finding the minimum value in vectors vectors - clojureПроблемы с файлами с памятью с отцовскими и дочерними процессами - cHow to convert json array to flex 4 (as3) array? - jsonJQuery Plugin for Bold Matching Letters (a way to display results in the Google Search Engine) - javascriptRemoving duplicates from multiple independent left unions - optimizationAndroid Layout Division - androidGetting file path using file upload control - c #How to populate TreeViewControl with hierarchy level? - c #All Articles