📄 storage.def
字号:
(*#@(#)Storage.def 4.1 Ultrix 7/17/90 *)(* $Header: Storage.def,v 1.5 84/05/19 11:39:36 powell Exp $ *)(* Definition module for standard memory allocation routines *)(* The size of the storage allocated or deallocated is specified in bits *)(* (as returned by system.tsize) *)(* The following note appears in Storage.def and memory.def *)(* NOTE: Modula-2 generates code to validate pointers before dereferencing them. Storage allocated by the New operation has an extra word at the beginning that points to the second word, which is where the pointer points. Thus, the pointer validation looks like cmpl rx,-4(rx) The word is set up by the New operation, which calls Storage.ALLOCATE asking for one more word than the user needs and sets things up. Thus, New and the pointer check work correctly with any ALLOCATE. This is set up whether compiling with -C or not, since some modules may do checking and others not. To avoid this check and eliminate the extra word, declare your pointers as follows: type UncheckedPointer = pointer @nocheck to Oblivion; If you need to call ALLOCATE instead of New, you must either declare the pointers to be @nocheck, or import ALLOCATE and DEALLOCATE from memory. ALLOCATE and DEALLOCATE in memory set up for the check. Remember, memory.allocate and memory.deallocate are for checked memory, Storage.ALLOCATE and Storage.DEALLOCATE are for @nocheck memory.*)DEFINITION MODULE Storage;FROM SYSTEM IMPORT ADDRESS;EXPORT QUALIFIED ALLOCATE, DEALLOCATE;PROCEDURE ALLOCATE(VAR p : ADDRESS; n : CARDINAL);PROCEDURE DEALLOCATE(VAR p : ADDRESS; n : CARDINAL);END Storage.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -