@@ -366,17 +366,10 @@ pub fn malloc(n isize) &u8 {
366
366
C.fprintf (C.stderr, c '_v_malloc %6d total %10d\n ' , n, total_m)
367
367
// print_backtrace()
368
368
}
369
+ vplayground_mlimit (n)
369
370
if n < 0 {
370
371
panic ('malloc(${n} < 0)' )
371
372
}
372
- $if vplayground ? {
373
- if n > 10000 {
374
- panic ('allocating more than 10 KB at once is not allowed in the V playground' )
375
- }
376
- if total_m > 50 * 1024 * 1024 {
377
- panic ('allocating more than 50 MB is not allowed in the V playground' )
378
- }
379
- }
380
373
mut res := & u8 (0 )
381
374
$if prealloc {
382
375
return unsafe { prealloc_malloc (n) }
@@ -409,17 +402,10 @@ pub fn malloc_noscan(n isize) &u8 {
409
402
C.fprintf (C.stderr, c 'malloc_noscan %6d total %10d\n ' , n, total_m)
410
403
// print_backtrace()
411
404
}
405
+ vplayground_mlimit (n)
412
406
if n < 0 {
413
407
panic ('malloc_noscan(${n} < 0)' )
414
408
}
415
- $if vplayground ? {
416
- if n > 10000 {
417
- panic ('allocating more than 10 KB at once is not allowed in the V playground' )
418
- }
419
- if total_m > 50 * 1024 * 1024 {
420
- panic ('allocating more than 50 MB is not allowed in the V playground' )
421
- }
422
- }
423
409
mut res := & u8 (0 )
424
410
$if prealloc {
425
411
return unsafe { prealloc_malloc (n) }
@@ -468,17 +454,10 @@ pub fn malloc_uncollectable(n isize) &u8 {
468
454
C.fprintf (C.stderr, c 'malloc_uncollectable %6d total %10d\n ' , n, total_m)
469
455
// print_backtrace()
470
456
}
457
+ vplayground_mlimit (n)
471
458
if n < 0 {
472
459
panic ('malloc_uncollectable(${n} < 0)' )
473
460
}
474
- $if vplayground ? {
475
- if n > 10000 {
476
- panic ('allocating more than 10 KB at once is not allowed in the V playground' )
477
- }
478
- if total_m > 50 * 1024 * 1024 {
479
- panic ('allocating more than 50 MB is not allowed in the V playground' )
480
- }
481
- }
482
461
mut res := & u8 (0 )
483
462
$if prealloc {
484
463
return unsafe { prealloc_malloc (n) }
@@ -604,14 +583,10 @@ pub fn vcalloc_noscan(n isize) &u8 {
604
583
total_m + = n
605
584
C.fprintf (C.stderr, c 'vcalloc_noscan %6d total %10d\n ' , n, total_m)
606
585
}
586
+ vplayground_mlimit (n)
607
587
$if prealloc {
608
588
return unsafe { prealloc_calloc (n) }
609
589
} $else $if gcboehm ? {
610
- $if vplayground ? {
611
- if n > 10000 {
612
- panic ('allocating more than 10 KB is not allowed in the playground' )
613
- }
614
- }
615
590
if n < 0 {
616
591
panic ('calloc_noscan(${n} < 0)' )
617
592
}
@@ -744,3 +719,13 @@ __global g_main_argc = int(0)
744
719
745
720
@[markused]
746
721
__global g_main_argv = unsafe { nil }
722
+
723
+ @[if vplayground ? ]
724
+ fn vplayground_mlimit (n isize) {
725
+ if n > 10000 {
726
+ panic ('allocating more than 10 KB at once is not allowed in the V playground' )
727
+ }
728
+ if total_m > 50 * 1024 * 1024 {
729
+ panic ('allocating more than 50 MB is not allowed in the V playground' )
730
+ }
731
+ }
0 commit comments