1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
# Test procedures for the NMEMIO interface.
#
include <mach.h>
define MT_HEAP 0 # test heap memory
define MT_STACK 1 # test stack memory
task memtest = t_memtest,
stack = t_stack,
realloc = t_realloc
# MEMTEST -- Task to test new memio interface.
procedure t_memtest ()
int model, nerr
pointer str, ptr
bool clgetb()
begin
if (clgetb ("stack"))
model = MT_STACK
else
model = MT_HEAP
# Check we can allocate a large array.
if (model == MT_HEAP) {
call eprintf ("\nBegin large heap malloc tests ....\n\n")
call malloc (str, 256000, TY_STRUCT)
call mfree (str, TY_STRUCT)
call eprintf ("Done\n\n")
# Print the memory layout.
call mt_print (TY_CHAR)
call mt_print (TY_SHORT)
call mt_print (TY_INT)
call mt_print (TY_BOOL)
call mt_print (TY_LONG)
call mt_print (TY_REAL)
call mt_print (TY_DOUBLE)
call mt_print (TY_COMPLEX)
call mt_print (TY_STRUCT)
call mt_print (TY_POINTER)
}
# Test Mem common assignments
call eprintf ("\nBegin assignment tests ....\n\n");
call mt_auto_b ("bool ", model)
call mt_auto_c ("char ", model)
call mt_auto_s ("short ", model)
call mt_auto_i ("int ", model)
call mt_auto_l ("long ", model)
call mt_auto_r ("real ", model)
call mt_auto_d ("double ", model)
call mt_auto_x ("complex", model)
call eprintf ("\nEnd assignment tests ....\n\n");
# Test string memory
call eprintf ("Begin Memc test\t\t");
call calloc (str, SZ_LINE, TY_CHAR)
call aclrc (Memc[str], SZ_LINE)
call strcpy ("test string", Memc[str], SZ_LINE)
call eprintf ("str = '%s' ch[2] = '%c' (should be 's')\n")
call pargstr (Memc[str])
call pargc (Memc[str+2])
call mfree (str, TY_CHAR)
# Test the struct memory
call eprintf ("\n\n")
call eprintf ("Begin struct test\n")
call mt_struct (model)
call eprintf ("Done\n")
# Test memory overflow and then underflow detection.
call eprintf ("\n\n")
call eprintf ("Testing overflow:\t")
nerr = 0
iferr ( call mt_overflow (TY_CHAR) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_SHORT) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_INT) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_BOOL) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_LONG) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_REAL) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_DOUBLE) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_COMPLEX) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_STRUCT) )
nerr = nerr + 1;
iferr ( call mt_overflow (TY_POINTER) )
nerr = nerr + 1;
call eprintf ("No. errors detected = %d of 10\t\tDone\n")
call pargi (nerr)
call eprintf ("Testing underflow:\t")
nerr = 0
iferr ( call mt_underflow (TY_CHAR) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_SHORT) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_INT) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_BOOL) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_LONG) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_REAL) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_DOUBLE) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_COMPLEX) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_STRUCT) )
nerr = nerr + 1;
iferr ( call mt_underflow (TY_POINTER) )
nerr = nerr + 1;
call eprintf ("No. errors detected = %d of 10\t\tDone\n")
call pargi (nerr)
# Note this test will leak 1024 bytes because of the error recovery.
call eprintf ("Testing invalid free:\t")
call calloc (ptr, 256, TY_REAL)
iferr ( call mfree (ptr, TY_INT) )
call eprintf ("Detected\t\t\t\t")
else
call eprintf ("Undetected\t\t\t\t")
call eprintf ("Done\n")
call eprintf ("Testing double free:\t")
call calloc (ptr, 256, TY_INT)
call mfree (ptr, TY_INT)
iferr ( call mfree (ptr, TY_INT) )
call eprintf ("Detected\t\t\t\t")
else
call eprintf ("Undetected\t\t\t\t")
call eprintf ("Done\n")
call eprintf ("Testing NULL free:\t")
iferr ( call mfree (NULL, TY_INT) )
call eprintf ("Detected\t\t\t\t")
else
call eprintf ("Undetected\t\t\t\t")
call eprintf ("Done\n")
call eprintf ("Testing recovered free:\n")
call calloc (str, SZ_LINE, TY_CHAR)
call eprintf ("Done\n")
call eprintf ("\n\nEnd of NMEMIO tests\n")
end
# Test the SALLOC routine, which allocates storage on the stack.
procedure t_stack ()
int bufsize
pointer sp, junk
int clglpi()
begin
call smark (sp)
while (clglpi ("buffer_size", bufsize) != EOF) {
call salloc (junk, bufsize, TY_CHAR)
call printf ("buffer pointer=%d, size=%d\n")
call pargi (junk)
call pargi (bufsize)
call flush (STDOUT)
}
call sfree (sp)
end
# Test the REALLOC procedure, used to change the size of a buffer.
# Work with two buffers, so that memory can be fragmented, forcing buffers
# to move.
procedure t_realloc()
pointer a, b
int i, sza, new_sza, szb, new_szb
begin
sza = SZ_FNAME
szb = SZ_LINE
call malloc (a, sza, TY_CHAR)
call malloc (b, szb, TY_CHAR)
call strcpy ("abcdefghijk", Memc[a], ARB)
call strcpy ("0123456789", Memc[b], ARB)
call eprintf ("a is at %d, size %d: %s\n")
call pargi (a)
call pargi (sza)
call pargstr (Memc[a])
call eprintf ("b is at %d, size %d: %s\n")
call pargi (b)
call pargi (szb)
call pargstr (Memc[b])
call eprintf ("-------------------------------\n")
for (i=1; i <= 10; i=i+1) {
if (i < 5) {
new_sza = sza + 512 ; new_szb = szb + 256
} else {
new_sza = sza + 256 ; new_szb = szb + 512
}
call realloc (a, new_sza, TY_CHAR)
call realloc (b, new_szb, TY_CHAR)
call eprintf ("%2d: a buf %d, size %d --> %d: %s\n")
call pargi (i)
call pargi (a)
call pargi (sza)
call pargi (new_sza)
call pargstr (Memc[a])
call eprintf ("%2d: b buf %d, size %d --> %d: %s\n")
call pargi (i)
call pargi (b)
call pargi (szb)
call pargi (new_szb)
call pargstr (Memc[b])
sza = new_sza
szb = new_szb
}
call mfree (a, TY_CHAR)
call mfree (b, TY_CHAR)
end
define SZ_TEST 640
define F_I1 Memi[$1]
define F_I2 Memi[$1+1]
define F_L1 Meml[$1+2]
define F_L2 Meml[$1+3]
define F_R1 Memr[$1+4]
define F_R2 Memr[$1+5]
define F_D1 Memd[P2D($1+8)]
define F_D2 Memd[P2D($1+10)]
define F_I3 Memi[$1+12]
define F_I4 Memi[$1+13]
define F_S1 Mems[P2S($1+14)]
define F_S2 Mems[P2S($1+15)]
procedure mt_struct (model)
int model
pointer sp, str
real x, y, z
double d1, d2, d3
int locva()
begin
if (model == MT_HEAP) {
call malloc (str, SZ_TEST, TY_STRUCT)
} else {
call smark (sp)
call salloc (str, SZ_TEST, TY_STRUCT)
}
F_I1(str) = 1
F_I2(str) = 2
F_L1(str) = 3
F_L2(str) = 4
F_R1(str) = 5.0
F_R2(str) = 6.0
F_D1(str) = 7.0
F_D2(str) = 8.0
F_I3(str) = 9
F_I4(str) = 10
F_S1(str) = 11
F_S2(str) = 12
x = 2.717 ; d1 = F_R1(str)
y = 2.717 ; d2 = 3.14159d0 ;
z = double(x) ; d3 = double(3.14159)
call eprintf ("\nd1=%.6g d2=%.6g d3=%.6g x=%.6g y=%.6g z=%.6g)\n\n")
call pargd (d1) ; call pargd (d2) ; call pargd (d3)
call pargr (x) ; call pargr (y) ; call pargr (z)
call eprintf ("Done Setting values ....\n\ntest = %d %d %d\n\n")
call pargi (str)
call pargi (locva(str))
call pargi (locva(F_I1(str)))
# call mdump (str, 64)
call eprintf ("I1 = %4d I2 = %4d \t%d %d\n")
call pargi (F_I1(str)) ; call pargi (F_I2(str))
call pargi (locva(F_I1(str))) ; call pargi (locva(F_I2(str)))
call eprintf ("L1 = %4d L2 = %4d \t%d %d\n")
call pargl (F_L1(str)) ; call pargl (F_L2(str))
call pargi (locva(F_L1(str))) ; call pargi (locva(F_L2(str)))
call eprintf ("R1 = %4.1f R2 = %4.1f \t%d %d\n")
call pargr (F_R1(str)) ; call pargr (F_R2(str))
call pargi (locva(F_R1(str))) ; call pargi (locva(F_R2(str)))
call eprintf ("D1 = %4.1f D2 = %4.1f \t%d %d\n")
call pargd (F_D1(str)) ; call pargd (F_D2(str))
call pargi (locva(F_D1(str))) ; call pargi (locva(F_D2(str)))
call eprintf ("I3 = %4d I4 = %4d \t%d %d\n")
call pargi (F_I3(str)) ; call pargi (F_I4(str))
call pargi (locva(F_I3(str))) ; call pargi (locva(F_I4(str)))
call eprintf ("S1 = %4d S2 = %4d \t%d %d\n")
call pargs (F_S1(str)) ; call pargs (F_S2(str))
call pargi (locva(F_S1(str))) ; call pargi (locva(F_S2(str)))
if (model == MT_HEAP)
call mfree (str, TY_STRUCT)
else
call sfree (sp)
end
define NVALS 3
procedure mt_print (dtype)
int dtype
int i, locva(), coerce()
real x
double xx
pointer p, bp, lwl
begin
call calloc (p, NVALS, dtype)
bp = coerce (p, dtype, TY_INT)
# Set the values.
for (i=0; i < NVALS; i=i+1) {
x = i ; xx = i
switch (dtype) {
case TY_BOOL: Memb[p+i] = TRUE
case TY_CHAR: Memc[p+i] = 'a' + i
case TY_SHORT: Mems[p+i] = i
case TY_INT: Memi[p+i] = i
case TY_LONG: Meml[p+i] = i
case TY_REAL: Memr[p+i] = x
case TY_DOUBLE: Memd[p+i] = xx
case TY_COMPLEX: Memx[p+i] = cmplx(x,-x)
case TY_STRUCT: Memi[p+i] = i
case TY_POINTER: Memi[p+i] = i
}
}
# Print the ptr header.
call eprintf ("\n")
call eprintf (" p = 0x%-15x %-16d\t%d\n")
call pargi (p) ; call pargi (p) ; call pargi (locva(Memi[bp]))
call eprintf (" fwa = 0x%-15x %-16d\t%d\n")
call pargi (bp-5) ; call pargi (Memi[bp-5])
call pargi (locva (Memi[bp-5]))
call eprintf (" lwl = 0x%-15x %-16d\t%d\n")
call pargi (bp-4) ; call pargi (Memi[bp-4])
call pargi (locva (Memi[bp-4]))
call eprintf (" dtype = 0x%-15x %-16d\t%d\n")
call pargi (bp-3) ; call mptype (dtype)
call pargi (locva (Memi[bp-3]))
call eprintf (" nelem = 0x%-15x %-16d\t%d\n")
call pargi (bp-2) ; call pargi (Memi[bp-2])
call pargi (locva (Memi[bp-2]))
call eprintf ("L sentinal = 0x%-15x %-16d\t%d\n")
call pargi (bp-1) ; call pargi (Memi[bp-1])
call pargi (locva (Memi[bp-1]))
# Print the values.
call eprintf (" data = ")
for (i=0; i < NVALS; i=i+1) {
switch (dtype) {
case TY_BOOL:
call eprintf (" %3b\t\t\t\t\t%-15d")
call pargb (Memb[p+i])
call pargi (locva(Memb[p+i]))
case TY_CHAR:
call eprintf (" %3c\t\t\t\t\t%-15d")
call pargc (Memc[p+i])
call pargi (locva(Memc[p+i]))
case TY_SHORT:
call eprintf (" %3d\t\t\t\t\t%-15d")
call pargs (Mems[p+i])
call pargi (locva(Mems[p+i]))
case TY_INT:
call eprintf (" %3d\t\t\t\t\t%-15d")
call pargi (Memi[p+i])
call pargi (locva(Memi[p+i]))
case TY_LONG:
call eprintf (" %3d\t\t\t\t\t%-15d")
call pargl (Meml[p+i])
call pargi (locva(Meml[p+i]))
case TY_REAL:
call eprintf (" %3g\t\t\t\t\t%-15d")
call pargr (Memr[p+i])
call pargi (locva(Memr[p+i]))
case TY_DOUBLE:
call eprintf (" %3g\t\t\t\t\t%-15d")
call pargd (Memd[p+i])
call pargi (locva(Memd[p+i]))
case TY_COMPLEX:
call eprintf (" %3x\t\t\t\t\t%-15d")
call pargx (Memx[p+i])
call pargi (locva(Memx[p+i]))
case TY_STRUCT:
call eprintf (" %3d\t\t\t\t\t%-15d")
call pargi (Memi[p+i])
call pargi (locva(Memi[p+i]))
case TY_POINTER:
call eprintf (" %3d\t\t\t\t\t%-15d")
call pargi (Memi[p+i])
call pargi (locva(Memi[p+i]))
}
call eprintf ("\n")
if (i < (NVALS-1))
call eprintf ("\t\t")
}
lwl = Memi[bp-4]
call eprintf ("U sentinal = 0x%-15x %-15d\t\t%d\n\n")
call pargi (lwl) ; call pargi (Memi[lwl])
call pargi (locva (Memi[lwl]))
call mfree (p, dtype)
end
procedure mt_overflow (dtype)
int dtype
int i
real x
double xx
pointer p
begin
call calloc (p, NVALS, dtype)
# Set the values.
for (i=0; i < NVALS + 4; i=i+1) {
x = i ; xx = i
switch (dtype) {
case TY_BOOL: Memb[p+i] = TRUE
case TY_CHAR: Memc[p+i] = 'a' + i
case TY_SHORT: Mems[p+i] = i
case TY_INT: Memi[p+i] = i
case TY_LONG: Meml[p+i] = i
case TY_REAL: Memr[p+i] = x
case TY_DOUBLE: Memd[p+i] = xx
case TY_COMPLEX: Memx[p+i] = cmplx(x,-x)
case TY_STRUCT: Memi[p+i] = i
case TY_POINTER: Memi[p+i] = i
}
}
call mfree (p, dtype)
end
procedure mt_underflow (dtype)
int dtype
int i
real x
double xx
pointer p
begin
call calloc (p, NVALS, dtype)
# Set the values.
for (i=0; i < NVALS; i=i+1) {
x = i ; xx = i
switch (dtype) {
case TY_BOOL: Memb[p+i] = TRUE ; Memb[p-1] = FALSE
case TY_CHAR: Memc[p+i] = 'a' + i ; Memc[p-1] = '0'
case TY_SHORT: Mems[p+i] = i ; Mems[p-1] = 999
case TY_INT: Memi[p+i] = i ; Memi[p-1] = 999
case TY_LONG: Meml[p+i] = i ; Meml[p-1] = 999
case TY_REAL: Memr[p+i] = x ; Memr[p-1] = 999
case TY_DOUBLE: Memd[p+i] = xx ; Memd[p-1] = 999
case TY_COMPLEX: Memx[p+i] = cmplx(x,-x) ; Memx[p-1] = 999
case TY_STRUCT: Memi[p+i] = i ; Memi[p-1] = 999
case TY_POINTER: Memi[p+i] = i ; Memi[p-1] = 999
}
}
call mfree (p, dtype)
end
procedure mptype (dtype)
int dtype
begin
switch (dtype) {
case TY_BOOL: call pargstr ("TY_BOOL ")
case TY_CHAR: call pargstr ("TY_CHAR ")
case TY_SHORT: call pargstr ("TY_SHORT ")
case TY_INT: call pargstr ("TY_INT ")
case TY_LONG: call pargstr ("TY_LONG ")
case TY_REAL: call pargstr ("TY_REAL ")
case TY_DOUBLE: call pargstr ("TY_DOUBLE ")
case TY_COMPLEX: call pargstr ("TY_COMPLEX")
case TY_STRUCT: call pargstr ("TY_STRUCT ")
case TY_POINTER: call pargstr ("TY_POINTER")
}
end
# Generic Mem_ test assignment.
define NAVALS 4
procedure mt_auto_b (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_BOOL)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_BOOL)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1)
Memb[ip+i] = TRUE
call eprintf ("[ %b %b %b %b ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargb (Memb[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_BOOL)
else
call sfree (sp)
end
procedure mt_auto_c (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_CHAR)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_CHAR)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1)
Memc[ip+i] = 'a' + i
call eprintf ("[ %-3c %-3c %-3c %-3c ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargc (Memc[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_CHAR)
else
call sfree (sp)
end
procedure mt_auto_s (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_SHORT)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_SHORT)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1)
Mems[ip+i] = i
call eprintf ("[ %-3d %-3d %-3d %-3d ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargs (Mems[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_SHORT)
else
call sfree (sp)
end
procedure mt_auto_i (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_INT)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_INT)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1)
Memi[ip+i] = i
call eprintf ("[ %-3d %-3d %-3d %-3d ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargi (Memi[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_INT)
else
call sfree (sp)
end
procedure mt_auto_l (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_LONG)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_LONG)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1)
Meml[ip+i] = i
call eprintf ("[ %-3d %-3d %-3d %-3d ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargl (Meml[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_LONG)
else
call sfree (sp)
end
procedure mt_auto_r (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_REAL)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_REAL)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1)
Memr[ip+i] = i
call eprintf ("[ %-3g %-3g %-3g %-3g ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargr (Memr[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_REAL)
else
call sfree (sp)
end
procedure mt_auto_d (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_DOUBLE)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_DOUBLE)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1)
Memd[ip+i] = i
call eprintf ("[ %-3g %-3g %-3g %-3g ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargd (Memd[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_DOUBLE)
else
call sfree (sp)
end
procedure mt_auto_x (ty, model)
char ty[ARB]
int model
int i
real x
pointer sp, ip
begin
call eprintf (" %s\t ")
call pargstr (ty)
if (model == MT_HEAP) {
call malloc (ip, NAVALS, TY_COMPLEX)
} else {
call smark (sp)
call salloc (ip, NAVALS, TY_COMPLEX)
}
call eprintf ("0x%-15x %-15d\t ")
call pargi(ip)
call pargi(ip)
x = 0.0
for (i=0; i < NAVALS; i=i+1) {
x = i
Memx[ip+i] = cmplx(x,0.1)
}
call eprintf ("[ %x %x %x %x ]\n")
for (i=0; i < NAVALS; i=i+1)
call pargx (Memx[ip+i])
if (model == MT_HEAP)
call mfree (ip, TY_COMPLEX)
else
call sfree (sp)
end
|