IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41160


Ignore:
Timestamp:
Nov 27, 2019, 11:06:01 AM (6 years ago)
Author:
eugene
Message:

improved memory check functions; ## and ### added as allowed comments

Location:
trunk/Ohana/src/opihi/cmd.basic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.basic/init.c

    r40522 r41160  
    7373  {1, "??",            list_vars,          "list variables *"},
    7474  {1, "#",             nop,                "a NOP function"},
     75  {1, "##",            nop,                "a NOP function"},
     76  {1, "###",           nop,                "a NOP function"},
    7577  {1, "local",         local,              "define local variables"},
    7678  {1, "macro",         macro,              "deal with the macros *"},
  • trunk/Ohana/src/opihi/cmd.basic/memory.c

    r14177 r41160  
    55 
    66  if (argc < 2) goto usage;
     7
     8  if (!strcasecmp (argv[1], "max-lines")) {
     9    if (argc != 3) goto usage;
     10    int MaxLines = atoi(argv[2]);
     11    ohana_memdump_set_maxlines (MaxLines);
     12    return TRUE;
     13  }
    714
    815  if (!strcasecmp (argv[1], "all")) {
     
    4350  }
    4451
     52  if (!strncasecmp ("strings", argv[1], strlen(argv[1]))) {
     53    ohana_memdump_strings_file (stderr, FALSE);
     54    return (TRUE);
     55  }
     56
    4557usage:
    46   gprint (GP_ERR, "USAGE: memory (all/leaks)\n");
     58  gprint (GP_ERR, "USAGE: memory (mode) [-max-lines]\n");
     59  gprint (GP_ERR, "USAGE: memory (max-lines) (N)\n");
     60  gprint (GP_ERR, " mode options: all, leaks, check, checkfree, variables, vectors, buffers, macros, commands, strings\n");
    4761  return (FALSE);
    4862}
  • trunk/Ohana/src/opihi/cmd.basic/test/if.sh

    r16894 r41160  
    320320 end
    321321end
     322
     323# check memleaks
     324macro memtest1
     325
     326 local a b i N
     327
     328 $i = 0
     329 $a = 1
     330
     331 memory check
     332 output /dev/null
     333 for i 0 1000
     334   if ($a == 1)
     335    echo "run"   
     336   end
     337 end   
     338 output stdout
     339 memory check
     340end
     341
     342# check memleaks
     343macro memtest2
     344
     345 local a b i N
     346
     347 $i = 0
     348 $a = 1
     349 $b = 2
     350
     351 memory check
     352 output /dev/null
     353 for i 0 1000
     354   if (($a == 1) && ($b == 2))
     355    echo "run"   
     356   end
     357 end   
     358 output stdout
     359 memory check
     360end
     361
     362# memory test using continue
     363macro memtest3
     364
     365 local a b i N
     366
     367 $i = 0
     368 $a = 1
     369 $b = 2
     370
     371 memory check
     372 output /dev/null
     373 for i 0 1000
     374   if (($a == 1) && ($b == 2))
     375    continue
     376    echo "run"   
     377   end
     378 end   
     379 output stdout
     380 memory check
     381end
     382
     383# memory test using continue
     384macro memtest4
     385
     386 local a b i N bool
     387
     388
     389 $i = 0
     390 $a = 1
     391 $b = 2
     392 $bool = 0
     393
     394 memory check
     395 output /dev/null
     396 for i 0 1000
     397   $bool = (($a == 1) && ($b == 2))
     398 end   
     399 output stdout
     400 memory check
     401end
  • trunk/Ohana/src/opihi/cmd.basic/test/macro.sh

    r10311 r41160  
    77# Is the macro working?
    88macro test_prep
     9 $test_var1 = check1
     10 $test_var2 = check2
     11 $var_count = $0
     12end
     13
     14# Is the macro working?
     15macro test_local
     16 local test_var test_var2 var_count
     17
    918 $test_var1 = check1
    1019 $test_var2 = check2
     
    4756 end
    4857end
     58
     59# Memory Test for macro
     60macro memtest2
     61
     62 $i = 0
     63 test_prep
     64
     65 memory check
     66 for i 0 10000
     67  test_prep
     68 end   
     69 memory check
     70 
     71end
     72
     73# Memory Test for macro
     74macro memtest3
     75
     76 $i = 0
     77 test_local
     78
     79 memory check
     80 for i 0 10000
     81  test_local
     82 end   
     83 memory check
     84 
     85end
Note: See TracChangeset for help on using the changeset viewer.