Ignore:
Timestamp:
Oct 24, 2008, 9:02:48 PM (17 years ago)
Author:
bird
Message:

kmk: recycle more allocate_variable_expand_* results.

File:
1 edited

Legend:

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

    r1929 r1931  
    6060};
    6161struct recycled_buffer *recycled_head;
    62 static char *
    63 allocated_variable_expand_3 (const char *line, unsigned int length,
    64                              unsigned int *value_lenp,
    65                              unsigned int *buffer_lengthp);
    66 static void
    67 recycle_variable_buffer (char *buffer, unsigned int length);
    68 
    69 #endif
     62#endif /* CONFIG_WITH_VALUE_LENGTH */
    7063
    7164
     
    10711064}
    10721065
    1073 /* Handles a special case for variable_expand_string2 where the variable
    1074    name is expanded.  This variant allows the variable_buffer to
    1075    be recycled and thus avoid bothering with a slow free implementation
    1076    (darwin is horrible here).  */
    1077 
    1078 static char *
     1066/* Initially created for handling a special case for variable_expand_string2
     1067   where the variable name is expanded and freed right afterwards.  This
     1068   variant allows the variable_buffer to be recycled and thus avoid bothering
     1069   with a slow free implementation. (Darwin is horrible slow.)  */
     1070
     1071char *
    10791072allocated_variable_expand_3 (const char *line, unsigned int length,
    10801073                             unsigned int *value_lenp,
     
    10901083
    10911084  value = variable_expand_string_2 (NULL, line, len, &eol);
    1092   *value_lenp = eol - value;
     1085  if (value_lenp)
     1086    *value_lenp = eol - value;
    10931087  *buffer_lengthp = variable_buffer_length;
    10941088
     
    11001094
    11011095/* recycle a buffer. */
    1102 static void
     1096
     1097void
    11031098recycle_variable_buffer (char *buffer, unsigned int length)
    11041099{
     
    11331128restore_variable_buffer (char *buf, unsigned int len)
    11341129{
     1130#ifndef CONFIG_WITH_VALUE_LENGTH
    11351131  free (variable_buffer);
     1132#else
     1133  if (variable_buffer)
     1134    recycle_variable_buffer (variable_buffer, variable_buffer_length);
     1135#endif
    11361136
    11371137  variable_buffer = buf;
Note: See TracChangeset for help on using the changeset viewer.