Re: [問題] 存取實體記憶體的方法?
==> typeotoco.bbs@ptt.cc (打字男) 提到:
> 請問一下 如何用 c或asm 去存取到實體記憶體呢?
> 我有這個需求,但對這方面觀念還不是很瞭解
> 希望能夠獲得一些指點
> 若有人可以寫幾行給小的參考 也會對我很有幫助
> 感謝
請參考 Borland C++ Builder 的 new 指令,可以取代以前的 malloc(),
The new operators offer dynamic storage allocation,
similar but superior to the standard library function malloc.
These allocation functions attempt to allocate size bytes
of storage. If successful, new returns a pointer to the
allocated memory.
If the allocation fails, the new operator will call the
new_handler function. The default behavior of new_handler is
to throw an exception of type bad_alloc. If you do not want
an exception to be thrown, use the nothrow version of operator
new. The nothrow versions return a null pointer result on
failure, instead of throwing an exception.
The default placement forms of operator new are reserved and
cannot be redefined. You can, however, overload the placement
form with a different signature (i.e. one having a different
number, or different type of arguments). The default placement
forms accept a pointer of type void, and perform no action
other than to return that pointer, unchanged. This can be
useful when you want to allocate an object at a known address.
Using the placement form of new can be tricky, as you must remember
to explicitly call the destructor for your object, and then free
the pre-allocated memory buffer. Do not call the delete operator
on an object allocated with the placement new operator.
A request for non-array allocation uses the appropriate operator
new() function. Any request for array allocation will call the
appropriate operator new[]() function. Remember to use the array
form of operator delete[](), when deallocating an array created
with operator new[]().
Note: Arrays of classes require that a default constructor be
defined in the class.
A request for allocation of 0 bytes returns a non-null pointer.
Repeated requests for zero-size allocations return distinct,
non-null pointers.
--
在每個人剛出生的時候 , 神早已為人類世界留下了伏筆 .
個人網頁 http://myweb.hinet.net/home4/l1032265/index.htm
--
☆ [Origin:椰林風情] [From: 122-124-13-219.dynamic.hine] [Login: **] [Post: **]
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
0
2
Programming 近期熱門文章
PTT數位生活區 即時熱門文章