WSTORAGE.LST 54 KB

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