WSTORAGE.LST 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  1. Listing:
  2. 1 (* Release 3.10 *)
  3. 2 (*-------------------------------------------------------------------------*
  4. 3 * *
  5. 4 * WSTORAGE.MOD - Dynamic allocations under Windows *
  6. 5 * *
  7. 6 * COPYRIGHT (C) 1987..1992 Clarion Software Corporation. *
  8. 7 * All Rights Reserved *
  9. 8 * *
  10. 9 *--------------------------------------------------------------------------*)
  11. 10
  12. 11 (*%F _fdata *)
  13. 12 (*# call(seg_name => null) *)
  14. 13 (*%E *)
  15. 14 (*# data(seg_name => null) *)
  16. 15 (*# check(stack=>off,
  17. 16 index=>off,
  18. 17 range=>off,
  19. 18 overflow=>off,
  20. 19 nil_ptr=>off) *)
  21. 20 (*# module(implementation=>off) *)
  22. 21
  23. 22 IMPLEMENTATION MODULE Storage;
  24. 23
  25. 24 IMPORT SYSTEM, Lib, Windows, CoreSig;
  26. 25 (*%T _mthread *)
  27. 26 IMPORT Process;
  28. 27 (*%E *)
  29. 28
  30. 29 CONST
  31. 30 EndMarker = 0FFFFH;
  32. 31 Align = 4;
  33. 32
  34. 33
  35. 34 (* This is DOS ONLY *)
  36. 35
  37. 36 PROCEDURE FarMakeHeap( Source : CARDINAL; (* base segment of heap *)
  38. 37 Size : CARDINAL (* size in paragraphs *)
  39. 38 ) : FarHeapRecPtr;
  40. ***** ^ undeclared identifier
  41. 39 VAR
  42. 40 storage,first,last : FarHeapRecPtr;
  43. ***** ^ undeclared identifier
  44. 41 BEGIN
  45. 42 (*%T _mthread *)
  46. 43 Process.Lock;
  47. ***** ^ not supported yet
  48. ***** ^ not supported yet
  49. 44 (*%E *)
  50. 45 storage := [Source:0];
  51. ***** ^ not supported yet
  52. ***** ^ not supported yet
  53. 46 first := [Source+1:0];
  54. ***** ^ not supported yet
  55. ***** ^ not supported yet
  56. 47 last := [Source+Size-1:0];
  57. ***** ^ not supported yet
  58. ***** ^ not supported yet
  59. 48 storage^.next := first;
  60. ***** ^ not supported yet
  61. ***** ^ not supported yet
  62. ***** ^ not supported yet
  63. 49 storage^.size := 0;
  64. ***** ^ not supported yet
  65. ***** ^ not supported yet
  66. 50 first^.next := last;
  67. ***** ^ not supported yet
  68. ***** ^ not supported yet
  69. ***** ^ not supported yet
  70. 51 last^.next := storage;
  71. ***** ^ not supported yet
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. 52 first^.size := Size-2;
  75. ***** ^ not supported yet
  76. ***** ^ not supported yet
  77. 53 last^.size := EndMarker;
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. 54 (*%T _mthread *)
  81. 55 Process.Unlock;
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. 56 (*%E *)
  85. 57 RETURN storage;
  86. ***** ^ not supported yet
  87. 58 END FarMakeHeap;
  88. ***** ^ not supported yet
  89. 59
  90. 60
  91. 61 PROCEDURE FarHeapAllocate(Source : FarHeapRecPtr; (* source heap *)
  92. ***** ^ undeclared identifier
  93. 62 VAR A : FarADDRESS; (* result *)
  94. ***** ^ undeclared identifier
  95. 63 Size : CARDINAL); (* request size in paragraphs *)
  96. 64
  97. 65 VAR
  98. 66 res,prev,split : FarHeapRecPtr;
  99. ***** ^ undeclared identifier
  100. 67 BEGIN
  101. 68 IF Source = MainHeap THEN
  102. ***** ^ not supported yet
  103. ***** ^ undeclared identifier
  104. 69 FarAllocate(A,Size);
  105. ***** ^ undeclared identifier
  106. ***** ^ not supported yet
  107. ***** ^ not supported yet
  108. 70 RETURN;
  109. 71 END;
  110. 72 (*%T _mthread *)
  111. 73 Process.Lock;
  112. ***** ^ not supported yet
  113. ***** ^ not supported yet
  114. 74 (*%E *)
  115. 75 IF Size=0 THEN INC(Size) END ;
  116. ***** ^ undeclared identifier
  117. ***** ^ not supported yet
  118. 76 prev := Source;
  119. ***** ^ not supported yet
  120. ***** ^ not supported yet
  121. 77 WHILE prev^.next^.size < Size DO
  122. ***** ^ not supported yet
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. 78 prev := prev^.next;
  126. ***** ^ not supported yet
  127. ***** ^ not supported yet
  128. ***** ^ not supported yet
  129. 79 END;
  130. 80 res := prev^.next;
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. 81 IF res^.size = EndMarker THEN (* heap run out of space *)
  135. ***** ^ not supported yet
  136. ***** ^ not supported yet
  137. 82 SYSTEM.EI ;
  138. ***** ^ not supported yet
  139. ***** ^ not supported yet
  140. 83 Lib.RunTimeError(CoreSig._FatalErrorPos(), 90H, 'FarHeapAllocate : Out Of Space');
  141. ***** ^ not supported yet
  142. ***** ^ not supported yet
  143. ***** ^ not supported yet
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. 84 END;
  148. 85 IF res^.size = Size THEN (* block correct size *)
  149. ***** ^ not supported yet
  150. ***** ^ not supported yet
  151. 86 prev^.next := res^.next;
  152. ***** ^ not supported yet
  153. ***** ^ not supported yet
  154. ***** ^ not supported yet
  155. ***** ^ not supported yet
  156. 87 ELSE (* split block, bottom half returned, top half linked to free chain *)
  157. 88 split := [CARDINAL(Seg(res^))+Size:0];
  158. ***** ^ not supported yet
  159. ***** ^ undeclared identifier
  160. ***** ^ not supported yet
  161. ***** ^ not supported yet
  162. 89 prev^.next := split;
  163. ***** ^ not supported yet
  164. ***** ^ not supported yet
  165. ***** ^ not supported yet
  166. 90 split^.next := res^.next;
  167. ***** ^ not supported yet
  168. ***** ^ not supported yet
  169. ***** ^ not supported yet
  170. ***** ^ not supported yet
  171. 91 split^.size := res^.size - Size;
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. ***** ^ not supported yet
  175. ***** ^ not supported yet
  176. 92 END;
  177. 93 (*%T _mthread *)
  178. 94 Process.Unlock;
  179. ***** ^ not supported yet
  180. ***** ^ not supported yet
  181. 95 (*%E *)
  182. 96 A := FarADR(res^);
  183. ***** ^ not supported yet
  184. ***** ^ undeclared identifier
  185. ***** ^ not supported yet
  186. 97 END FarHeapAllocate;
  187. ***** ^ not supported yet
  188. 98
  189. 99
  190. 100 PROCEDURE FarHeapAvail(Source: FarHeapRecPtr) : CARDINAL;
  191. ***** ^ undeclared identifier
  192. 101 (* returns the largest block size available for allocation in paragraphs *)
  193. 102 VAR
  194. 103 size : CARDINAL;
  195. 104 p : FarHeapRecPtr;
  196. ***** ^ undeclared identifier
  197. 105 BEGIN
  198. 106 IF Source = MainHeap THEN
  199. ***** ^ not supported yet
  200. ***** ^ undeclared identifier
  201. 107 RETURN 1000H;
  202. 108 END;
  203. 109 (*%T _mthread *)
  204. 110 Process.Lock;
  205. ***** ^ not supported yet
  206. ***** ^ not supported yet
  207. 111 (*%E *)
  208. 112 p := Source^.next;
  209. ***** ^ not supported yet
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. 113 size := 0;
  213. 114 WHILE p^.size <> EndMarker DO
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. 115 IF p^.size>size THEN size := p^.size END;
  217. ***** ^ not supported yet
  218. ***** ^ not supported yet
  219. ***** ^ not supported yet
  220. ***** ^ not supported yet
  221. 116 p := p^.next;
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. ***** ^ not supported yet
  225. 117 END;
  226. 118 (*%T _mthread *)
  227. 119 Process.Unlock;
  228. ***** ^ not supported yet
  229. ***** ^ not supported yet
  230. 120 (*%E *)
  231. 121 RETURN size;
  232. 122 END FarHeapAvail;
  233. ***** ^ not supported yet
  234. 123
  235. 124
  236. 125 PROCEDURE FarHeapTotalAvail(Source: FarHeapRecPtr) : CARDINAL;
  237. ***** ^ undeclared identifier
  238. 126 (* returns the total block size available for allocation in paragraphs *)
  239. 127 VAR
  240. 128 size : CARDINAL;
  241. 129 p : FarHeapRecPtr;
  242. ***** ^ undeclared identifier
  243. 130 BEGIN
  244. 131 IF Source = MainHeap THEN
  245. ***** ^ not supported yet
  246. ***** ^ undeclared identifier
  247. 132 RETURN 0FFFFH;
  248. 133 END;
  249. 134 (*%T _mthread *)
  250. 135 Process.Lock;
  251. ***** ^ not supported yet
  252. ***** ^ not supported yet
  253. 136 (*%E *)
  254. 137 p := Source^.next;
  255. ***** ^ not supported yet
  256. ***** ^ not supported yet
  257. ***** ^ not supported yet
  258. 138 size := 0;
  259. 139 WHILE p^.size <> EndMarker DO
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. 140 INC(size,p^.size);
  263. ***** ^ undeclared identifier
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. 141 p := p^.next;
  267. ***** ^ not supported yet
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. 142 END;
  271. 143 (*%T _mthread *)
  272. 144 Process.Unlock;
  273. ***** ^ not supported yet
  274. ***** ^ not supported yet
  275. 145 (*%E *)
  276. 146 RETURN size;
  277. 147 END FarHeapTotalAvail;
  278. ***** ^ not supported yet
  279. 148
  280. 149
  281. 150
  282. 151 PROCEDURE FarHeapDeallocate(Source : FarHeapRecPtr; (* source heap *)
  283. ***** ^ undeclared identifier
  284. 152 VAR A: FarADDRESS;
  285. ***** ^ undeclared identifier
  286. 153 Size : CARDINAL ); (* size of block
  287. 154 in paragraphs *)
  288. 155 VAR
  289. 156 target,prev,split : FarHeapRecPtr;
  290. ***** ^ undeclared identifier
  291. 157 tseg : CARDINAL;
  292. 158 BEGIN
  293. 159 IF Source = MainHeap THEN
  294. ***** ^ not supported yet
  295. ***** ^ undeclared identifier
  296. 160 FarDeallocate(A,Size);
  297. ***** ^ undeclared identifier
  298. ***** ^ not supported yet
  299. ***** ^ not supported yet
  300. 161 RETURN;
  301. 162 END;
  302. 163 IF (CARDINAL(Seg(A^))=0)OR(CARDINAL(Ofs(A^))<>0) THEN
  303. ***** ^ undeclared identifier
  304. ***** ^ not supported yet
  305. ***** ^ undeclared identifier
  306. ***** ^ not supported yet
  307. 164 Lib.RunTimeError(CoreSig._FatalErrorPos(), 91H, 'FarHeapDeallocate : Invalid Argument');
  308. ***** ^ not supported yet
  309. ***** ^ not supported yet
  310. ***** ^ not supported yet
  311. ***** ^ not supported yet
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. 165 END;
  315. 166 (*%T _mthread *)
  316. 167 Process.Lock;
  317. ***** ^ not supported yet
  318. ***** ^ not supported yet
  319. 168 (*%E *)
  320. 169 IF Size=0 THEN INC(Size) END ;
  321. ***** ^ undeclared identifier
  322. ***** ^ not supported yet
  323. 170 target := A;
  324. ***** ^ not supported yet
  325. ***** ^ not supported yet
  326. 171 prev := Source;
  327. ***** ^ not supported yet
  328. ***** ^ not supported yet
  329. 172 tseg := Seg(target^);
  330. ***** ^ undeclared identifier
  331. ***** ^ not supported yet
  332. 173 WHILE CARDINAL(Seg(prev^.next^)) < tseg DO
  333. ***** ^ undeclared identifier
  334. ***** ^ not supported yet
  335. ***** ^ not supported yet
  336. 174 prev := prev^.next;
  337. ***** ^ not supported yet
  338. ***** ^ not supported yet
  339. ***** ^ not supported yet
  340. 175 END;
  341. 176 IF CARDINAL(Seg(prev^))+prev^.size = tseg THEN (* amalgamate with prev *)
  342. ***** ^ undeclared identifier
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. ***** ^ not supported yet
  346. 177 prev^.size := prev^.size + Size;
  347. ***** ^ not supported yet
  348. ***** ^ not supported yet
  349. ***** ^ not supported yet
  350. ***** ^ not supported yet
  351. 178 target := prev;
  352. ***** ^ not supported yet
  353. ***** ^ not supported yet
  354. 179 ELSIF CARDINAL(Seg(prev^))+prev^.size > tseg THEN (* Heap corrupt *)
  355. ***** ^ undeclared identifier
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. ***** ^ not supported yet
  359. 180 SYSTEM.EI;
  360. ***** ^ not supported yet
  361. ***** ^ not supported yet
  362. 181 Lib.RunTimeError(CoreSig._FatalErrorPos(), 92H, 'FarHeapDeallocate : Heap Corrupt');
  363. ***** ^ not supported yet
  364. ***** ^ not supported yet
  365. ***** ^ not supported yet
  366. ***** ^ not supported yet
  367. ***** ^ not supported yet
  368. ***** ^ not supported yet
  369. 182 ELSE
  370. 183 (* link after prev *)
  371. 184 target^.next := prev^.next;
  372. ***** ^ not supported yet
  373. ***** ^ not supported yet
  374. ***** ^ not supported yet
  375. ***** ^ not supported yet
  376. 185 prev^.next := target;
  377. ***** ^ not supported yet
  378. ***** ^ not supported yet
  379. ***** ^ not supported yet
  380. 186 target^.size := Size;
  381. ***** ^ not supported yet
  382. ***** ^ not supported yet
  383. 187 END;
  384. 188 IF (target^.next^.size <> EndMarker)
  385. ***** ^ not supported yet
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. 189 AND (CARDINAL(Seg(target^.next^)) = CARDINAL(Seg(target^))+target^.size) THEN
  389. ***** ^ undeclared identifier
  390. ***** ^ not supported yet
  391. ***** ^ not supported yet
  392. ***** ^ undeclared identifier
  393. ***** ^ not supported yet
  394. ***** ^ not supported yet
  395. ***** ^ not supported yet
  396. 190 (* amalgamate with next block *)
  397. 191 target^.size := target^.size+target^.next^.size;
  398. ***** ^ not supported yet
  399. ***** ^ not supported yet
  400. ***** ^ not supported yet
  401. ***** ^ not supported yet
  402. ***** ^ not supported yet
  403. ***** ^ not supported yet
  404. ***** ^ not supported yet
  405. 192 target^.next := target^.next^.next;
  406. ***** ^ not supported yet
  407. ***** ^ not supported yet
  408. ***** ^ not supported yet
  409. ***** ^ not supported yet
  410. ***** ^ not supported yet
  411. 193 END;
  412. 194 A := SYSTEM.FarNIL;
  413. ***** ^ not supported yet
  414. ***** ^ not supported yet
  415. ***** ^ not supported yet
  416. 195 (*%T _mthread *)
  417. 196 Process.Unlock;
  418. ***** ^ not supported yet
  419. ***** ^ not supported yet
  420. 197 (*%E *)
  421. 198 END FarHeapDeallocate;
  422. ***** ^ not supported yet
  423. 199
  424. 200
  425. 201 PROCEDURE FarHeapChangeAlloc(Source : FarHeapRecPtr; (* source heap *)
  426. ***** ^ undeclared identifier
  427. 202 A : FarADDRESS; (* block to change *)
  428. ***** ^ undeclared identifier
  429. 203 OldSize, (* old size of block *)
  430. 204 NewSize : CARDINAL) (* new size of block *)
  431. 205 (* in paragraphs *)
  432. 206 : BOOLEAN; (* if sucessful *)
  433. 207
  434. 208 (* This procedure attempts to change the size of an allocated block
  435. 209 It returns TRUE if succeeded (only expansion can fail)
  436. 210 *)
  437. 211
  438. 212 VAR
  439. 213 target,prev,
  440. 214 split : FarHeapRecPtr;
  441. ***** ^ undeclared identifier
  442. 215 tseg : CARDINAL;
  443. 216 result : BOOLEAN;
  444. 217 extendsize : CARDINAL;
  445. 218 Res : FarADDRESS;
  446. ***** ^ undeclared identifier
  447. 219 BEGIN
  448. 220 IF Source = MainHeap THEN
  449. ***** ^ not supported yet
  450. ***** ^ undeclared identifier
  451. 221 RETURN FALSE;
  452. 222 END;
  453. 223 IF (CARDINAL(Seg(A^))=0)OR(CARDINAL(Ofs(A^))<>0) THEN
  454. ***** ^ undeclared identifier
  455. ***** ^ not supported yet
  456. ***** ^ undeclared identifier
  457. ***** ^ not supported yet
  458. 224 Lib.RunTimeError(CoreSig._FatalErrorPos(), 93H, 'FarHeapChangeAlloc : Invalid Argument');
  459. ***** ^ not supported yet
  460. ***** ^ not supported yet
  461. ***** ^ not supported yet
  462. ***** ^ not supported yet
  463. ***** ^ not supported yet
  464. ***** ^ not supported yet
  465. 225 END;
  466. 226 IF OldSize = NewSize THEN RETURN TRUE END;
  467. 227 IF OldSize > NewSize THEN
  468. 228 target := [CARDINAL(Seg(A^))+NewSize:0];
  469. ***** ^ not supported yet
  470. ***** ^ undeclared identifier
  471. ***** ^ not supported yet
  472. ***** ^ not supported yet
  473. 229 FarHeapDeallocate(Source,target,OldSize-NewSize);
  474. ***** ^ not supported yet
  475. ***** ^ not supported yet
  476. ***** ^ not supported yet
  477. ***** ^ not supported yet
  478. 230 RETURN TRUE;
  479. 231 END;
  480. 232 extendsize := NewSize-OldSize;
  481. 233 (*%T _mthread *)
  482. 234 Process.Lock;
  483. ***** ^ not supported yet
  484. ***** ^ not supported yet
  485. 235 (*%E *)
  486. 236 target := A;
  487. ***** ^ not supported yet
  488. ***** ^ not supported yet
  489. 237 prev := Source;
  490. ***** ^ not supported yet
  491. ***** ^ not supported yet
  492. 238 tseg := Seg(target^);
  493. ***** ^ undeclared identifier
  494. ***** ^ not supported yet
  495. 239 WHILE CARDINAL(Seg(prev^.next^)) < tseg DO
  496. ***** ^ undeclared identifier
  497. ***** ^ not supported yet
  498. ***** ^ not supported yet
  499. 240 prev := prev^.next;
  500. ***** ^ not supported yet
  501. ***** ^ not supported yet
  502. ***** ^ not supported yet
  503. 241 END;
  504. 242 IF (prev^.next^.size <> EndMarker) AND
  505. ***** ^ not supported yet
  506. ***** ^ not supported yet
  507. ***** ^ not supported yet
  508. 243 (CARDINAL(Seg(prev^.next^)) = CARDINAL(Seg(target^))+OldSize) AND
  509. ***** ^ undeclared identifier
  510. ***** ^ not supported yet
  511. ***** ^ not supported yet
  512. ***** ^ undeclared identifier
  513. ***** ^ not supported yet
  514. 244 (extendsize <= prev^.next^.size) THEN
  515. ***** ^ not supported yet
  516. ***** ^ not supported yet
  517. ***** ^ not supported yet
  518. 245 IF (extendsize = prev^.next^.size) THEN
  519. ***** ^ not supported yet
  520. ***** ^ not supported yet
  521. ***** ^ not supported yet
  522. 246 prev^.next := prev^.next^.next
  523. ***** ^ not supported yet
  524. ***** ^ not supported yet
  525. ***** ^ not supported yet
  526. ***** ^ not supported yet
  527. ***** ^ not supported yet
  528. 247 ELSE
  529. 248 split := [CARDINAL(Seg(target^))+NewSize:0];
  530. ***** ^ not supported yet
  531. ***** ^ undeclared identifier
  532. ***** ^ not supported yet
  533. ***** ^ not supported yet
  534. 249 split^.next := prev^.next^.next;
  535. ***** ^ not supported yet
  536. ***** ^ not supported yet
  537. ***** ^ not supported yet
  538. ***** ^ not supported yet
  539. ***** ^ not supported yet
  540. 250 split^.size := prev^.next^.size - extendsize;
  541. ***** ^ not supported yet
  542. ***** ^ not supported yet
  543. ***** ^ not supported yet
  544. ***** ^ not supported yet
  545. ***** ^ not supported yet
  546. 251 prev^.next := split;
  547. ***** ^ not supported yet
  548. ***** ^ not supported yet
  549. ***** ^ not supported yet
  550. 252 END;
  551. 253 result := TRUE;
  552. 254 ELSE
  553. 255 result := FALSE;
  554. 256 END;
  555. 257 (*%T _mthread *)
  556. 258 Process.Unlock;
  557. ***** ^ not supported yet
  558. ***** ^ not supported yet
  559. 259 (*%E *)
  560. 260 RETURN result;
  561. 261 END FarHeapChangeAlloc;
  562. ***** ^ not supported yet
  563. 262
  564. 263
  565. 264
  566. 265 PROCEDURE FarHeapChangeSize(Source : FarHeapRecPtr; (* source heap *)
  567. ***** ^ undeclared identifier
  568. 266 VAR A : FarADDRESS; (* block to change *)
  569. ***** ^ undeclared identifier
  570. 267 OldSize, (* old size of block *)
  571. 268 NewSize : CARDINAL ); (* new size of block
  572. 269 in paragraphs *)
  573. 270
  574. 271 (*
  575. 272 This procedure will change the size of an allocated block
  576. 273 avoiding any copy of data if possible
  577. 274 calls HeapChangeAlloc
  578. 275 *)
  579. 276
  580. 277 VAR
  581. 278 na : FarADDRESS;
  582. ***** ^ undeclared identifier
  583. 279 BEGIN
  584. 280 IF Source = MainHeap THEN
  585. ***** ^ not supported yet
  586. ***** ^ undeclared identifier
  587. 281 Lib.RunTimeError(CoreSig._FatalErrorPos(), 94H, 'FarHeapChangeSize : Out Of Memory');
  588. ***** ^ not supported yet
  589. ***** ^ not supported yet
  590. ***** ^ not supported yet
  591. ***** ^ not supported yet
  592. ***** ^ not supported yet
  593. ***** ^ not supported yet
  594. 282 RETURN;
  595. 283 END;
  596. 284 IF NOT FarHeapChangeAlloc ( Source, A, OldSize, NewSize ) THEN
  597. ***** ^ not supported yet
  598. ***** ^ not supported yet
  599. ***** ^ not supported yet
  600. ***** ^ not supported yet
  601. 285 FarHeapAllocate(Source,na,NewSize);
  602. ***** ^ not supported yet
  603. ***** ^ not supported yet
  604. ***** ^ not supported yet
  605. ***** ^ not supported yet
  606. 286 Lib.FarWordMove(A, na, OldSize*8);
  607. ***** ^ not supported yet
  608. ***** ^ not supported yet
  609. ***** ^ not supported yet
  610. ***** ^ not supported yet
  611. ***** ^ not supported yet
  612. 287 FarHeapDeallocate(Source,A,OldSize);
  613. ***** ^ not supported yet
  614. ***** ^ not supported yet
  615. ***** ^ not supported yet
  616. ***** ^ not supported yet
  617. 288 A := na;
  618. ***** ^ not supported yet
  619. ***** ^ not supported yet
  620. 289 END;
  621. 290 END FarHeapChangeSize;
  622. ***** ^ not supported yet
  623. 291
  624. 292
  625. 293 PROCEDURE NearMakeHeap(Source: NearADDRESS; Size: CARDINAL): NearHeapRecPtr;
  626. ***** ^ undeclared identifier
  627. ***** ^ undeclared identifier
  628. 294 (* ========== *)
  629. 295 VAR Storage, FirstFree: NearHeapRecPtr;
  630. ***** ^ undeclared identifier
  631. 296 BEGIN
  632. 297 Size := (Size DIV Align) * Align;
  633. 298 IF Size < 10 THEN
  634. 299 Lib.RunTimeError(CoreSig._FatalErrorPos(), 95H, 'NearMakeHeap: Size Too Small');
  635. ***** ^ not supported yet
  636. ***** ^ not supported yet
  637. ***** ^ not supported yet
  638. ***** ^ not supported yet
  639. ***** ^ not supported yet
  640. ***** ^ not supported yet
  641. 300 END;
  642. 301 Storage := NearHeapRecPtr(Source);
  643. ***** ^ not supported yet
  644. ***** ^ undeclared identifier
  645. ***** ^ not supported yet
  646. 302 Storage^.next := NearHeapRecPtr(CARDINAL(Source)+Align);
  647. ***** ^ not supported yet
  648. ***** ^ not supported yet
  649. ***** ^ undeclared identifier
  650. ***** ^ not supported yet
  651. ***** ^ not supported yet
  652. 303 Storage^.size :=4;
  653. ***** ^ not supported yet
  654. ***** ^ not supported yet
  655. 304 FirstFree := Storage^.next;
  656. ***** ^ not supported yet
  657. ***** ^ not supported yet
  658. ***** ^ not supported yet
  659. 305 FirstFree^.size := Size - Align;
  660. ***** ^ not supported yet
  661. ***** ^ not supported yet
  662. 306 FirstFree^.next := SYSTEM.NearNIL;
  663. ***** ^ not supported yet
  664. ***** ^ not supported yet
  665. ***** ^ not supported yet
  666. ***** ^ not supported yet
  667. 307 RETURN Storage;
  668. ***** ^ not supported yet
  669. 308 END NearMakeHeap;
  670. ***** ^ not supported yet
  671. 309
  672. 310 PROCEDURE NearHeapAllocate(Source: NearHeapRecPtr; VAR A: NearADDRESS; Size: CARDINAL);
  673. ***** ^ undeclared identifier
  674. ***** ^ undeclared identifier
  675. 311 (* ======== *)
  676. 312 VAR Base, Free, New: NearHeapRecPtr;
  677. ***** ^ undeclared identifier
  678. 313 BEGIN
  679. 314 IF Size = 0 THEN INC(Size) END;
  680. ***** ^ undeclared identifier
  681. ***** ^ not supported yet
  682. 315 Size := (( (Size+Align-1) DIV Align) * Align) + Align;
  683. 316 IF Size = 0 THEN
  684. 317 Size:=MAX(CARDINAL);
  685. ***** ^ undeclared identifier
  686. ***** ^ not supported yet
  687. 318 END;
  688. 319 Base := Source;
  689. ***** ^ not supported yet
  690. ***** ^ not supported yet
  691. 320 LOOP
  692. 321 Free := Base^.next;
  693. ***** ^ not supported yet
  694. ***** ^ not supported yet
  695. ***** ^ not supported yet
  696. 322 IF Free = SYSTEM.NearNIL THEN
  697. ***** ^ not supported yet
  698. ***** ^ not supported yet
  699. ***** ^ not supported yet
  700. 323 IF Check THEN
  701. ***** ^ undeclared identifier
  702. 324 Lib.RunTimeError(CoreSig._FatalErrorPos(), 96H, 'NearHeapAllocate: Out Of Memory');
  703. ***** ^ not supported yet
  704. ***** ^ not supported yet
  705. ***** ^ not supported yet
  706. ***** ^ not supported yet
  707. ***** ^ not supported yet
  708. ***** ^ not supported yet
  709. 325 ELSE
  710. 326 A := SYSTEM.NearNIL;
  711. ***** ^ not supported yet
  712. ***** ^ not supported yet
  713. ***** ^ not supported yet
  714. 327 RETURN;
  715. 328 END;
  716. 329 ELSIF Free^.size >= Size THEN
  717. ***** ^ not supported yet
  718. ***** ^ not supported yet
  719. 330 EXIT;
  720. 331 END;
  721. 332 Base := Free;
  722. ***** ^ not supported yet
  723. ***** ^ not supported yet
  724. 333 END;
  725. 334 IF Free^.size = Size THEN
  726. ***** ^ not supported yet
  727. ***** ^ not supported yet
  728. 335 Base^.next := Free^.next;
  729. ***** ^ not supported yet
  730. ***** ^ not supported yet
  731. ***** ^ not supported yet
  732. ***** ^ not supported yet
  733. 336 ELSE
  734. 337 New := NearHeapRecPtr(CARDINAL(Free)+Size);
  735. ***** ^ not supported yet
  736. ***** ^ undeclared identifier
  737. ***** ^ not supported yet
  738. ***** ^ not supported yet
  739. 338 Base^.next := New;
  740. ***** ^ not supported yet
  741. ***** ^ not supported yet
  742. ***** ^ not supported yet
  743. 339 New^.size := Free^.size - Size;
  744. ***** ^ not supported yet
  745. ***** ^ not supported yet
  746. ***** ^ not supported yet
  747. ***** ^ not supported yet
  748. 340 New^.next := Free^.next;
  749. ***** ^ not supported yet
  750. ***** ^ not supported yet
  751. ***** ^ not supported yet
  752. ***** ^ not supported yet
  753. 341 END;
  754. 342 IF ClearOnAllocate THEN
  755. ***** ^ undeclared identifier
  756. 343 Lib.WordFill ( ADDRESS(CARDINAL(Free)+Align) , (Size-Align) DIV 2 , 0 );
  757. ***** ^ not supported yet
  758. ***** ^ not supported yet
  759. ***** ^ undeclared identifier
  760. ***** ^ not supported yet
  761. ***** ^ not supported yet
  762. ***** ^ not supported yet
  763. 344 END;
  764. 345 A := NearADDRESS(CARDINAL(Free)+Align);
  765. ***** ^ not supported yet
  766. ***** ^ undeclared identifier
  767. ***** ^ not supported yet
  768. ***** ^ not supported yet
  769. 346 END NearHeapAllocate;
  770. ***** ^ not supported yet
  771. 347
  772. 348 PROCEDURE Merge(PrevRec, LowRec, HighRec, Source: NearHeapRecPtr);
  773. ***** ^ undeclared identifier
  774. 349
  775. 350 BEGIN
  776. 351 IF (LowRec = SYSTEM.NearNIL) OR (HighRec = SYSTEM.NearNIL) THEN RETURN END;
  777. ***** ^ not supported yet
  778. ***** ^ not supported yet
  779. ***** ^ not supported yet
  780. ***** ^ not supported yet
  781. ***** ^ not supported yet
  782. ***** ^ not supported yet
  783. 352 IF (LowRec = Source) THEN RETURN END;
  784. ***** ^ not supported yet
  785. ***** ^ not supported yet
  786. 353 IF NearHeapRecPtr(CARDINAL(LowRec)+LowRec^.size) # HighRec THEN RETURN END;
  787. ***** ^ undeclared identifier
  788. ***** ^ not supported yet
  789. ***** ^ not supported yet
  790. ***** ^ not supported yet
  791. ***** ^ not supported yet
  792. 354 INC(LowRec^.size, HighRec^.size);
  793. ***** ^ undeclared identifier
  794. ***** ^ not supported yet
  795. ***** ^ not supported yet
  796. ***** ^ not supported yet
  797. ***** ^ not supported yet
  798. 355 LowRec^.next:=HighRec^.next;
  799. ***** ^ not supported yet
  800. ***** ^ not supported yet
  801. ***** ^ not supported yet
  802. ***** ^ not supported yet
  803. 356 PrevRec^.next:=LowRec;
  804. ***** ^ not supported yet
  805. ***** ^ not supported yet
  806. ***** ^ not supported yet
  807. 357 RETURN;
  808. 358 END Merge;
  809. ***** ^ not supported yet
  810. 359
  811. 360 PROCEDURE NearHeapDeallocate(Source: NearHeapRecPtr; VAR A: NearADDRESS; Size: CARDINAL );
  812. ***** ^ undeclared identifier
  813. ***** ^ undeclared identifier
  814. 361
  815. 362 VAR
  816. 363 Curr, Base, Free: NearHeapRecPtr;
  817. ***** ^ undeclared identifier
  818. 364
  819. 365 BEGIN
  820. 366 Size := (( (Size+Align-1) DIV Align) * Align) + Align;
  821. 367 Curr := NearHeapRecPtr(CARDINAL(A) - Align);
  822. ***** ^ not supported yet
  823. ***** ^ undeclared identifier
  824. ***** ^ not supported yet
  825. ***** ^ not supported yet
  826. 368 A := SYSTEM.NearNIL;
  827. ***** ^ not supported yet
  828. ***** ^ not supported yet
  829. ***** ^ not supported yet
  830. 369 IF Curr = SYSTEM.NearNIL THEN
  831. ***** ^ not supported yet
  832. ***** ^ not supported yet
  833. ***** ^ not supported yet
  834. 370 Lib.RunTimeError(CoreSig._FatalErrorPos(), 97H, 'NearHeapDeallocate: Invalid Argument');
  835. ***** ^ not supported yet
  836. ***** ^ not supported yet
  837. ***** ^ not supported yet
  838. ***** ^ not supported yet
  839. ***** ^ not supported yet
  840. ***** ^ not supported yet
  841. 371 END;
  842. 372 Base:=Source;
  843. ***** ^ not supported yet
  844. ***** ^ not supported yet
  845. 373 LOOP
  846. 374 Free := Base^.next;
  847. ***** ^ not supported yet
  848. ***** ^ not supported yet
  849. ***** ^ not supported yet
  850. 375 IF (Free = SYSTEM.NearNIL) OR (CARDINAL(Curr) < CARDINAL(Free)) THEN EXIT; END;
  851. ***** ^ not supported yet
  852. ***** ^ not supported yet
  853. ***** ^ not supported yet
  854. ***** ^ not supported yet
  855. ***** ^ not supported yet
  856. 376 Base := Free;
  857. ***** ^ not supported yet
  858. ***** ^ not supported yet
  859. 377 END;
  860. 378 IF (CARDINAL(Base) + Base^.size = CARDINAL(Curr)) AND (Base # Source) THEN
  861. ***** ^ not supported yet
  862. ***** ^ not supported yet
  863. ***** ^ not supported yet
  864. ***** ^ not supported yet
  865. ***** ^ not supported yet
  866. ***** ^ not supported yet
  867. 379 INC ( Base^.size , Size );
  868. ***** ^ undeclared identifier
  869. ***** ^ not supported yet
  870. ***** ^ not supported yet
  871. ***** ^ not supported yet
  872. 380 Curr := Base;
  873. ***** ^ not supported yet
  874. ***** ^ not supported yet
  875. 381 ELSE
  876. 382 Base^.next := Curr;
  877. ***** ^ not supported yet
  878. ***** ^ not supported yet
  879. ***** ^ not supported yet
  880. 383 Curr^.next := Free;
  881. ***** ^ not supported yet
  882. ***** ^ not supported yet
  883. ***** ^ not supported yet
  884. 384 Curr^.size := Size;
  885. ***** ^ not supported yet
  886. ***** ^ not supported yet
  887. 385 END;
  888. 386 IF CARDINAL(Curr) + Curr^.size = CARDINAL(Free) THEN
  889. ***** ^ not supported yet
  890. ***** ^ not supported yet
  891. ***** ^ not supported yet
  892. ***** ^ not supported yet
  893. 387 INC ( Curr^.size, Free^.size);
  894. ***** ^ undeclared identifier
  895. ***** ^ not supported yet
  896. ***** ^ not supported yet
  897. ***** ^ not supported yet
  898. ***** ^ not supported yet
  899. 388 Curr^.next := Free^.next;
  900. ***** ^ not supported yet
  901. ***** ^ not supported yet
  902. ***** ^ not supported yet
  903. ***** ^ not supported yet
  904. 389 END;
  905. 390 END NearHeapDeallocate;
  906. ***** ^ not supported yet
  907. 391
  908. 392 PROCEDURE NearHeapAvail(Source: NearHeapRecPtr): CARDINAL;
  909. ***** ^ undeclared identifier
  910. 393
  911. 394 VAR
  912. 395 Curr: NearHeapRecPtr;
  913. ***** ^ undeclared identifier
  914. 396 Size: CARDINAL;
  915. 397 BEGIN
  916. 398 Curr := Source;
  917. ***** ^ not supported yet
  918. ***** ^ not supported yet
  919. 399 Size := 0;
  920. 400 WHILE Curr # SYSTEM.NearNIL DO
  921. ***** ^ not supported yet
  922. ***** ^ not supported yet
  923. ***** ^ not supported yet
  924. 401 IF Size < Curr^.size THEN
  925. ***** ^ not supported yet
  926. ***** ^ not supported yet
  927. 402 Size := Curr^.size;
  928. ***** ^ not supported yet
  929. ***** ^ not supported yet
  930. 403 END;
  931. 404 Curr := Curr^.next;
  932. ***** ^ not supported yet
  933. ***** ^ not supported yet
  934. ***** ^ not supported yet
  935. 405 END;
  936. 406 RETURN Size - Align;
  937. 407 END NearHeapAvail;
  938. ***** ^ not supported yet
  939. 408
  940. 409
  941. 410 PROCEDURE NearHeapTotalAvail(Source: NearHeapRecPtr): CARDINAL;
  942. ***** ^ undeclared identifier
  943. 411
  944. 412 VAR
  945. 413 Curr: NearHeapRecPtr;
  946. ***** ^ undeclared identifier
  947. 414 Size: CARDINAL;
  948. 415 BEGIN
  949. 416 Curr := Source^.next;
  950. ***** ^ not supported yet
  951. ***** ^ not supported yet
  952. ***** ^ not supported yet
  953. 417 Size := 0;
  954. 418 WHILE Curr # SYSTEM.NearNIL DO
  955. ***** ^ not supported yet
  956. ***** ^ not supported yet
  957. ***** ^ not supported yet
  958. 419 INC ( Size , Curr^.size - Align);
  959. ***** ^ undeclared identifier
  960. ***** ^ not supported yet
  961. ***** ^ not supported yet
  962. ***** ^ not supported yet
  963. 420 Curr := Curr^.next;
  964. ***** ^ not supported yet
  965. ***** ^ not supported yet
  966. ***** ^ not supported yet
  967. 421 END;
  968. 422 RETURN Size;
  969. 423 END NearHeapTotalAvail;
  970. ***** ^ not supported yet
  971. 424
  972. 425
  973. 426
  974. 427 PROCEDURE NearHeapChangeSize(Source: NearHeapRecPtr; VAR A: NearADDRESS;
  975. ***** ^ undeclared identifier
  976. ***** ^ undeclared identifier
  977. 428 OldSize, NewSize : CARDINAL);
  978. 429
  979. 430 VAR
  980. 431 Curr, NextRec, PrevRec, NewRec: NearHeapRecPtr;
  981. ***** ^ undeclared identifier
  982. 432 SplitSize: CARDINAL;
  983. 433 OldA: NearADDRESS;
  984. ***** ^ undeclared identifier
  985. 434 BEGIN
  986. 435 NewSize := (( (NewSize+Align-1) DIV Align) * Align) + Align;
  987. 436 OldSize := (( (OldSize+Align-1) DIV Align) * Align) + Align;
  988. 437 IF OldSize = NewSize THEN RETURN END;
  989. 438 Curr:=NearHeapRecPtr(CARDINAL(A)-Align);
  990. ***** ^ not supported yet
  991. ***** ^ undeclared identifier
  992. ***** ^ not supported yet
  993. ***** ^ not supported yet
  994. 439 NextRec:=Source;
  995. ***** ^ not supported yet
  996. ***** ^ not supported yet
  997. 440 PrevRec:=Source;
  998. ***** ^ not supported yet
  999. ***** ^ not supported yet
  1000. 441 LOOP
  1001. 442 IF NextRec = SYSTEM.NearNIL THEN EXIT END;
  1002. ***** ^ not supported yet
  1003. ***** ^ not supported yet
  1004. ***** ^ not supported yet
  1005. 443 IF CARDINAL(NextRec) > CARDINAL(Curr) THEN EXIT END;
  1006. ***** ^ not supported yet
  1007. ***** ^ not supported yet
  1008. 444 PrevRec:=NextRec;
  1009. ***** ^ not supported yet
  1010. ***** ^ not supported yet
  1011. 445 NextRec:=NextRec^.next;
  1012. ***** ^ not supported yet
  1013. ***** ^ not supported yet
  1014. ***** ^ not supported yet
  1015. 446 END;
  1016. 447 IF OldSize > NewSize THEN
  1017. 448 SplitSize:=OldSize-NewSize;
  1018. 449 Curr^.size:=NewSize;
  1019. ***** ^ not supported yet
  1020. ***** ^ not supported yet
  1021. 450 NewRec:=NearHeapRecPtr(CARDINAL(Curr)+NewSize);
  1022. ***** ^ not supported yet
  1023. ***** ^ undeclared identifier
  1024. ***** ^ not supported yet
  1025. ***** ^ not supported yet
  1026. 451 NewRec^.size:=SplitSize;
  1027. ***** ^ not supported yet
  1028. ***** ^ not supported yet
  1029. 452 NewRec^.next:=PrevRec^.next;
  1030. ***** ^ not supported yet
  1031. ***** ^ not supported yet
  1032. ***** ^ not supported yet
  1033. ***** ^ not supported yet
  1034. 453 PrevRec^.next:=NewRec;
  1035. ***** ^ not supported yet
  1036. ***** ^ not supported yet
  1037. ***** ^ not supported yet
  1038. 454 Merge(PrevRec, NewRec, NextRec, Source);
  1039. ***** ^ not supported yet
  1040. ***** ^ not supported yet
  1041. ***** ^ not supported yet
  1042. ***** ^ not supported yet
  1043. ***** ^ not supported yet
  1044. 455 RETURN ;
  1045. 456 END;
  1046. 457 IF NearHeapRecPtr(CARDINAL(Curr)+OldSize) = NextRec THEN (* Next Block is free *)
  1047. ***** ^ undeclared identifier
  1048. ***** ^ not supported yet
  1049. ***** ^ not supported yet
  1050. ***** ^ not supported yet
  1051. 458 Curr^.size := OldSize;
  1052. ***** ^ not supported yet
  1053. ***** ^ not supported yet
  1054. 459 Merge(PrevRec, Curr, NextRec, Source);
  1055. ***** ^ not supported yet
  1056. ***** ^ not supported yet
  1057. ***** ^ not supported yet
  1058. ***** ^ not supported yet
  1059. ***** ^ not supported yet
  1060. 460 IF OldSize = NewSize THEN
  1061. 461 PrevRec^.next := Curr^.next;
  1062. ***** ^ not supported yet
  1063. ***** ^ not supported yet
  1064. ***** ^ not supported yet
  1065. ***** ^ not supported yet
  1066. 462 RETURN;
  1067. 463 ELSE
  1068. 464 NewRec := NearHeapRecPtr(CARDINAL(Curr)+NewSize);
  1069. ***** ^ not supported yet
  1070. ***** ^ undeclared identifier
  1071. ***** ^ not supported yet
  1072. ***** ^ not supported yet
  1073. 465 NewRec^.size := Curr^.size-NewSize;
  1074. ***** ^ not supported yet
  1075. ***** ^ not supported yet
  1076. ***** ^ not supported yet
  1077. ***** ^ not supported yet
  1078. 466 NewRec^.next := Curr^.next;
  1079. ***** ^ not supported yet
  1080. ***** ^ not supported yet
  1081. ***** ^ not supported yet
  1082. ***** ^ not supported yet
  1083. 467 PrevRec^.next := NewRec;
  1084. ***** ^ not supported yet
  1085. ***** ^ not supported yet
  1086. ***** ^ not supported yet
  1087. 468 RETURN;
  1088. 469 END;
  1089. 470 END;
  1090. 471 OldA:=A;
  1091. ***** ^ not supported yet
  1092. ***** ^ not supported yet
  1093. 472 NearHeapDeallocate(Source, A, OldSize);
  1094. ***** ^ not supported yet
  1095. ***** ^ not supported yet
  1096. ***** ^ not supported yet
  1097. ***** ^ not supported yet
  1098. 473 NearHeapAllocate(Source, A, NewSize);
  1099. ***** ^ not supported yet
  1100. ***** ^ not supported yet
  1101. ***** ^ not supported yet
  1102. ***** ^ not supported yet
  1103. 474 Lib.WordMove(ADR(OldA), ADR(A), OldSize DIV 2);
  1104. ***** ^ not supported yet
  1105. ***** ^ not supported yet
  1106. ***** ^ undeclared identifier
  1107. ***** ^ not supported yet
  1108. ***** ^ undeclared identifier
  1109. ***** ^ not supported yet
  1110. ***** ^ not supported yet
  1111. 475 RETURN;
  1112. 476 END NearHeapChangeSize;
  1113. ***** ^ not supported yet
  1114. 477
  1115. 478 PROCEDURE NearHeapChangeAlloc(Source: NearHeapRecPtr; A: NearADDRESS;
  1116. ***** ^ undeclared identifier
  1117. ***** ^ undeclared identifier
  1118. 479 OldSize, NewSize : CARDINAL): BOOLEAN;
  1119. 480
  1120. 481 VAR
  1121. 482 Curr, NextRec, PrevRec, NewRec: NearHeapRecPtr;
  1122. ***** ^ undeclared identifier
  1123. 483 SplitSize: CARDINAL;
  1124. 484 BEGIN
  1125. 485 NewSize := (( (NewSize+Align-1) DIV Align) * Align) + Align;
  1126. 486 OldSize := (( (OldSize+Align-1) DIV Align) * Align) + Align;
  1127. 487 IF OldSize = NewSize THEN RETURN TRUE END;
  1128. 488 Curr:=NearHeapRecPtr(CARDINAL(A)-Align);
  1129. ***** ^ not supported yet
  1130. ***** ^ undeclared identifier
  1131. ***** ^ not supported yet
  1132. ***** ^ not supported yet
  1133. 489 PrevRec:=Source;
  1134. ***** ^ not supported yet
  1135. ***** ^ not supported yet
  1136. 490 NextRec:=Source;
  1137. ***** ^ not supported yet
  1138. ***** ^ not supported yet
  1139. 491 LOOP
  1140. 492 IF NextRec = SYSTEM.NearNIL THEN EXIT END;
  1141. ***** ^ not supported yet
  1142. ***** ^ not supported yet
  1143. ***** ^ not supported yet
  1144. 493 IF CARDINAL(NextRec) > CARDINAL(Curr) THEN EXIT END;
  1145. ***** ^ not supported yet
  1146. ***** ^ not supported yet
  1147. 494 PrevRec:=NextRec;
  1148. ***** ^ not supported yet
  1149. ***** ^ not supported yet
  1150. 495 NextRec:=NextRec^.next;
  1151. ***** ^ not supported yet
  1152. ***** ^ not supported yet
  1153. ***** ^ not supported yet
  1154. 496 END;
  1155. 497 IF OldSize > NewSize THEN
  1156. 498 SplitSize:=OldSize-NewSize;
  1157. 499 Curr^.size:=NewSize;
  1158. ***** ^ not supported yet
  1159. ***** ^ not supported yet
  1160. 500 NewRec:=NearHeapRecPtr(CARDINAL(Curr)+NewSize);
  1161. ***** ^ not supported yet
  1162. ***** ^ undeclared identifier
  1163. ***** ^ not supported yet
  1164. ***** ^ not supported yet
  1165. 501 NewRec^.size:=SplitSize;
  1166. ***** ^ not supported yet
  1167. ***** ^ not supported yet
  1168. 502 NewRec^.next:=PrevRec^.next;
  1169. ***** ^ not supported yet
  1170. ***** ^ not supported yet
  1171. ***** ^ not supported yet
  1172. ***** ^ not supported yet
  1173. 503 PrevRec^.next:=NewRec;
  1174. ***** ^ not supported yet
  1175. ***** ^ not supported yet
  1176. ***** ^ not supported yet
  1177. 504 Merge(PrevRec, NewRec, NextRec, Source);
  1178. ***** ^ not supported yet
  1179. ***** ^ not supported yet
  1180. ***** ^ not supported yet
  1181. ***** ^ not supported yet
  1182. ***** ^ not supported yet
  1183. 505 RETURN TRUE;
  1184. 506 END;
  1185. 507 IF NearHeapRecPtr(CARDINAL(Curr)+OldSize) = NextRec THEN (* Next Block is free *)
  1186. ***** ^ undeclared identifier
  1187. ***** ^ not supported yet
  1188. ***** ^ not supported yet
  1189. ***** ^ not supported yet
  1190. 508 Curr^.size := OldSize;
  1191. ***** ^ not supported yet
  1192. ***** ^ not supported yet
  1193. 509 Merge(PrevRec, Curr, NextRec, Source);
  1194. ***** ^ not supported yet
  1195. ***** ^ not supported yet
  1196. ***** ^ not supported yet
  1197. ***** ^ not supported yet
  1198. ***** ^ not supported yet
  1199. 510 IF OldSize = NewSize THEN
  1200. 511 PrevRec^.next := Curr^.next;
  1201. ***** ^ not supported yet
  1202. ***** ^ not supported yet
  1203. ***** ^ not supported yet
  1204. ***** ^ not supported yet
  1205. 512 ELSE
  1206. 513 NewRec := NearHeapRecPtr(CARDINAL(Curr)+NewSize);
  1207. ***** ^ not supported yet
  1208. ***** ^ undeclared identifier
  1209. ***** ^ not supported yet
  1210. ***** ^ not supported yet
  1211. 514 NewRec^.size := OldSize-NewSize;
  1212. ***** ^ not supported yet
  1213. ***** ^ not supported yet
  1214. 515 NewRec^.next := Curr^.next;
  1215. ***** ^ not supported yet
  1216. ***** ^ not supported yet
  1217. ***** ^ not supported yet
  1218. ***** ^ not supported yet
  1219. 516 PrevRec^.next := NewRec;
  1220. ***** ^ not supported yet
  1221. ***** ^ not supported yet
  1222. ***** ^ not supported yet
  1223. 517 END;
  1224. 518 RETURN TRUE;
  1225. 519 ELSE
  1226. 520 RETURN FALSE;
  1227. 521 END;
  1228. 522 END NearHeapChangeAlloc;
  1229. ***** ^ not supported yet
  1230. 523
  1231. 524
  1232. 525 TYPE
  1233. 526 HANDLEPtr = POINTER TO Windows.HANDLE;
  1234. ***** ^ not supported yet
  1235. 527
  1236. 528
  1237. 529 PROCEDURE NearDeallocate(VAR a: NearADDRESS; size: CARDINAL);
  1238. ***** ^ undeclared identifier
  1239. 530
  1240. 531 BEGIN
  1241. 532 IF ORD(Windows.LocalFree(Windows.HANDLE(a))) # 0 THEN END;
  1242. ***** ^ undeclared identifier
  1243. ***** ^ not supported yet
  1244. ***** ^ not supported yet
  1245. ***** ^ not supported yet
  1246. ***** ^ not supported yet
  1247. ***** ^ not supported yet
  1248. 533 a:= NearADDRESS(NIL);
  1249. ***** ^ not supported yet
  1250. ***** ^ undeclared identifier
  1251. ***** ^ not supported yet
  1252. 534 END NearDeallocate;
  1253. ***** ^ not supported yet
  1254. 535
  1255. 536 PROCEDURE NearAllocate(VAR a: NearADDRESS; size: CARDINAL);
  1256. ***** ^ undeclared identifier
  1257. 537
  1258. 538 VAR
  1259. 539 mode: CARDINAL;
  1260. 540 h: Windows.HANDLE;
  1261. ***** ^ not supported yet
  1262. 541 BEGIN
  1263. 542 IF size = 0 THEN size := 2 END;
  1264. 543 mode := Windows.LMEM_FIXED;
  1265. ***** ^ not supported yet
  1266. ***** ^ not supported yet
  1267. 544 IF ClearOnAllocate THEN
  1268. ***** ^ undeclared identifier
  1269. 545 mode := mode + Windows.LMEM_ZEROINIT;
  1270. ***** ^ not supported yet
  1271. ***** ^ not supported yet
  1272. 546 END;
  1273. 547 h := Windows.LocalAlloc(mode, size);
  1274. ***** ^ not supported yet
  1275. ***** ^ not supported yet
  1276. ***** ^ not supported yet
  1277. ***** ^ not supported yet
  1278. 548 IF ORD(h) = 0 THEN
  1279. ***** ^ undeclared identifier
  1280. ***** ^ not supported yet
  1281. 549 Lib.RunTimeError(CoreSig._FatalErrorPos(), 98H, 'NearAllocate: Out Of Memory');
  1282. ***** ^ not supported yet
  1283. ***** ^ not supported yet
  1284. ***** ^ not supported yet
  1285. ***** ^ not supported yet
  1286. ***** ^ not supported yet
  1287. ***** ^ not supported yet
  1288. 550 END;
  1289. 551 a := NearADDRESS(h);
  1290. ***** ^ not supported yet
  1291. ***** ^ undeclared identifier
  1292. ***** ^ not supported yet
  1293. 552 END NearAllocate;
  1294. ***** ^ not supported yet
  1295. 553
  1296. 554 PROCEDURE NearAvailable(size: CARDINAL) : BOOLEAN;
  1297. 555
  1298. 556 BEGIN
  1299. 557 RETURN TRUE;
  1300. 558 END NearAvailable;
  1301. ***** ^ not supported yet
  1302. 559
  1303. 560 PROCEDURE FarAllocate (VAR a: FarADDRESS; size: CARDINAL);
  1304. ***** ^ undeclared identifier
  1305. 561
  1306. 562 BEGIN
  1307. 563 a := Windows.GlobalLock(Windows.GlobalAlloc(Windows.GMEM_MOVEABLE,LONGCARD(size)));
  1308. ***** ^ not supported yet
  1309. ***** ^ not supported yet
  1310. ***** ^ not supported yet
  1311. ***** ^ not supported yet
  1312. ***** ^ not supported yet
  1313. ***** ^ not supported yet
  1314. ***** ^ not supported yet
  1315. ***** ^ undeclared identifier
  1316. ***** ^ not supported yet
  1317. 564 END FarAllocate;
  1318. ***** ^ not supported yet
  1319. 565
  1320. 566 PROCEDURE FarDeallocate(VAR a: FarADDRESS; size: CARDINAL);
  1321. ***** ^ undeclared identifier
  1322. 567
  1323. 568 VAR h : Windows.HANDLE;
  1324. ***** ^ not supported yet
  1325. 569 BEGIN
  1326. 570 h := CARDINAL(Windows.GlobalHandle(Seg(a^)));
  1327. ***** ^ not supported yet
  1328. ***** ^ not supported yet
  1329. ***** ^ not supported yet
  1330. ***** ^ undeclared identifier
  1331. ***** ^ not supported yet
  1332. 571 Windows.GlobalUnlock(h);
  1333. ***** ^ not supported yet
  1334. ***** ^ not supported yet
  1335. ***** ^ not supported yet
  1336. 572 Windows.GlobalFree(h);
  1337. ***** ^ not supported yet
  1338. ***** ^ not supported yet
  1339. ***** ^ not supported yet
  1340. 573 a := FarNIL;
  1341. ***** ^ not supported yet
  1342. ***** ^ undeclared identifier
  1343. 574 END FarDeallocate;
  1344. ***** ^ not supported yet
  1345. 575
  1346. 576 PROCEDURE FarAvailable(size: CARDINAL ): BOOLEAN;
  1347. 577
  1348. 578 BEGIN
  1349. 579 RETURN TRUE;
  1350. 580 END FarAvailable;
  1351. ***** ^ not supported yet
  1352. 581
  1353. 582 PROCEDURE SegAllocate(Size: CARDINAL): CARDINAL;
  1354. 583 VAR
  1355. 584 a : FarADDRESS;
  1356. ***** ^ undeclared identifier
  1357. 585 BEGIN
  1358. 586 FarAllocate(a,Size);
  1359. ***** ^ not supported yet
  1360. ***** ^ not supported yet
  1361. ***** ^ not supported yet
  1362. 587 RETURN Seg(a^);
  1363. ***** ^ undeclared identifier
  1364. ***** ^ not supported yet
  1365. 588 END SegAllocate;
  1366. ***** ^ not supported yet
  1367. 589
  1368. 590 PROCEDURE SegDeallocate(Sel: CARDINAL; Size: CARDINAL);
  1369. 591 VAR a : FarADDRESS;
  1370. ***** ^ undeclared identifier
  1371. 592 BEGIN
  1372. 593 a := [Sel:0];
  1373. ***** ^ not supported yet
  1374. ***** ^ not supported yet
  1375. 594 FarDeallocate(a,Size);
  1376. ***** ^ not supported yet
  1377. ***** ^ not supported yet
  1378. ***** ^ not supported yet
  1379. 595 END SegDeallocate;
  1380. ***** ^ not supported yet
  1381. 596
  1382. 597
  1383. 598
  1384. 599 BEGIN
  1385. 600 MainHeap:=[0:0FFFFH];
  1386. ***** ^ undeclared identifier
  1387. ***** ^ not supported yet
  1388. 601 END Storage.
  1389. ***** ^ not supported yet
  1390. 787 errors