Changeset 2754 for trunk/src/kmk


Ignore:
Timestamp:
Jan 24, 2015, 12:00:41 AM (10 years ago)
Author:
bird
Message:

kmk: Save 20+ MB of memory for chopped receipt command lines by freeing them after we're done evaluating a target.

Location:
trunk/src/kmk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/commands.c

    r2753 r2754  
    633633
    634634
    635 #ifdef KMK
     635#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
    636636/* This is for saving memory in func_commands. */
    637637void
    638638free_chopped_commands (struct commands *cmds)
    639639{
    640   if (cmds && cmds->command_lines != 0)
     640  if (   cmds
     641      && cmds->command_lines != 0
     642      && cmds->refs == 0)
    641643    {
    642644      unsigned idx = cmds->ncommand_lines;
     
    645647      free (cmds->command_lines);
    646648      free (cmds->lines_flags);
    647       cmds->command_lines = NULL;
    648       cmds->lines_flags = NULL;
    649     }
    650 }
    651 
    652 
    653 #endif /* CONFIG_WITH_COMMANDS_FUNC */
     649      cmds->command_lines = 0;
     650      cmds->lines_flags = 0;
     651      cmds->ncommand_lines = 0;
     652    }
     653}
     654
     655
     656#endif /* CONFIG_WITH_MEMORY_OPTIMIZATIONS */
    654657/* Execute the commands to remake FILE.  If they are currently executing,
    655658   return or have already finished executing, just return.  Otherwise,
  • trunk/src/kmk/commands.h

    r2753 r2754  
    5757void delete_child_targets (struct child *child);
    5858void chop_commands (struct commands *cmds);
    59 #ifdef KMK
     59#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
    6060void free_chopped_commands (struct commands *cmd);
    6161#endif
  • trunk/src/kmk/job.c

    r2592 r2754  
    10161016  child->file->cmds->refs--;
    10171017  if (   !child->file->intermediate
    1018       && !child->file->pat_variables
    1019       && child->file->cmds->refs == 0)
    1020     {
    1021       struct commands *cmds = child->file->cmds;
    1022       unsigned int i;
    1023 
    1024       for (i = 0; i < cmds->ncommand_lines; ++i)
    1025         {
    1026           free (cmds->command_lines[i]);
    1027           cmds->command_lines[i] = 0;
    1028         }
    1029       free (cmds->command_lines);
    1030       cmds->command_lines = 0;
    1031       free (cmds->lines_flags);
    1032       cmds->lines_flags = 0;
    1033       cmds->ncommand_lines = 0;
    1034     }
     1018      && !child->file->pat_variables)
     1019    free_chopped_commands(child->file->cmds);
    10351020#endif /* CONFIG_WITH_MEMORY_OPTIMIZATIONS */
    10361021
  • trunk/src/kmk/remake.c

    r2753 r2754  
    13301330#endif
    13311331
    1332 #ifdef KMK
     1332#ifdef CONFIG_WITH_MEMORY_OPTIMIZATIONS
    13331333    /* We're done with this command, so free the memory held by the chopped
    13341334       command lines. Saves heap for the compilers & linkers. */
Note: See TracChangeset for help on using the changeset viewer.