Changeset 1863 for trunk/src/kmk/read.c


Ignore:
Timestamp:
Oct 14, 2008, 11:46:23 AM (17 years ago)
Author:
bird
Message:

kmk: Allocation caches for nameseq, dep and idep. next: variable.

File:
1 edited

Legend:

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

    r1862 r1863  
    10171017          /* Parse the list of file names.  */
    10181018          p2 = p;
     1019#ifndef CONFIG_WITH_ALLOC_CACHES
    10191020          files = multi_glob (parse_file_seq (&p2, '\0',
    10201021                                              sizeof (struct nameseq),
    10211022                                              1),
    10221023                              sizeof (struct nameseq));
     1024#else
     1025          files = multi_glob (parse_file_seq (&p2, '\0', &nameseq_cache, 1),
     1026                              &nameseq_cache);
     1027#endif
    10231028          free (p);
    10241029
     
    10381043              int r;
    10391044
     1045#ifndef CONFIG_WITH_ALLOC_CACHES
    10401046              free (files);
     1047#else
     1048              alloccache_free (&nameseq_cache, files);
     1049#endif
    10411050              files = next;
    10421051
     
    12511260           looking for targets.  */
    12521261        *colonp = '\0';
     1262#ifndef CONFIG_WITH_ALLOC_CACHES
    12531263        filenames = multi_glob (parse_file_seq (&p2, '\0',
    12541264                                                sizeof (struct nameseq),
    12551265                                                1),
    12561266                                sizeof (struct nameseq));
     1267#else
     1268        filenames = multi_glob (parse_file_seq (&p2, '\0', &nameseq_cache, 1),
     1269                                &nameseq_cache);
     1270#endif
    12571271        *p2 = ':';
    12581272
     
    14061420          {
    14071421            struct nameseq *target;
     1422#ifndef CONFIG_WITH_ALLOC_CACHES
    14081423            target = parse_file_seq (&p2, ':', sizeof (struct nameseq), 1);
     1424#else
     1425            target = parse_file_seq (&p2, ':', &nameseq_cache, 1);
     1426#endif
    14091427            ++p2;
    14101428            if (target == 0)
     
    14161434            if (pattern_percent == 0)
    14171435              fatal (fstart, _("target pattern contains no `%%' (target `%s')"), target->name); /* bird */
     1436#ifndef CONFIG_WITH_ALLOC_CACHES
    14181437            free (target);
     1438#else
     1439            alloccache_free (&nameseq_cache, target);
     1440#endif
    14191441          }
    14201442        else
     
    24242446
    24252447      nextf = filenames->next;
     2448#ifndef CONFIG_WITH_ALLOC_CACHES
    24262449      free (filenames);
     2450#else
     2451      alloccache_free (&nameseq_cache, filenames);
     2452#endif
    24272453
    24282454      /* Check for special targets.  Do it here instead of, say, snap_deps()
     
    29592985   If STRIP is nonzero, strip `./'s off the beginning.  */
    29602986
     2987#ifndef CONFIG_WITH_ALLOC_CACHES
    29612988struct nameseq *
    29622989parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip)
     2990#else
     2991struct nameseq *
     2992parse_file_seq (char **stringp, int stopchar, struct alloccache *cache, int strip)
     2993#endif
    29632994{
    29642995  struct nameseq *new = 0;
     
    30793110
    30803111      /* Add it to the front of the chain.  */
    3081 #if !defined(KMK) || !defined(NO_ARCHIVES)
     3112#ifndef CONFIG_WITH_ALLOC_CACHES
    30823113      new1 = xmalloc (size);
    30833114#else
    3084       if (sizeof (struct dep) == size) /* use the cache */
    3085         new1 = (struct nameseq *)alloc_dep ();
    3086       else
    3087         new1 = xmalloc (size);
     3115      new1 = (struct nameseq *)alloccache_alloc (cache);
    30883116#endif
    30893117      new1->name = name;
     
    31383166                   Edit it out of the chain and free its storage.  */
    31393167                lastn->next = n->next;
     3168#ifndef CONFIG_WITH_ALLOC_CACHES
    31403169                free (n);
     3170#else
     3171                alloccache_free (cache, n);
     3172#endif
    31413173                /* LASTN->next is the new stopping elt for the loop below.  */
    31423174                n = lastn->next;
     
    31583190                lastn = new1;
    31593191                new1 = new1->next;
     3192#ifndef CONFIG_WITH_ALLOC_CACHES
    31603193                free (lastn);
     3194#else
     3195                alloccache_free (cache, lastn);
     3196#endif
    31613197              }
    31623198            else
     
    37943830   that have room for additional info.  */
    37953831
     3832#ifndef CONFIG_WITH_ALLOC_CACHES
    37963833struct nameseq *
    37973834multi_glob (struct nameseq *chain, unsigned int size)
     3835#else
     3836struct nameseq *
     3837multi_glob (struct nameseq *chain, struct alloccache *cache)
     3838#endif
    37983839{
    37993840  void dir_setup_glob (glob_t *);
     
    38963937#endif /* !NO_ARCHIVES */
    38973938                  {
    3898 #if !defined(KMK) && !defined(NO_ARCHIVES)
     3939#ifndef CONFIG_WITH_ALLOC_CACHES
    38993940                    struct nameseq *elt = xmalloc (size);
    3900 #else
    3901                     struct nameseq *elt = size == sizeof(struct dep)
    3902                                         ? (void *)alloc_dep() : xmalloc (size);
    3903 #endif
    39043941                    memset (elt, '\0', size);
     3942#else
     3943                    struct nameseq *elt = alloccache_calloc (cache);
     3944#endif
    39053945                    elt->name = strcache_add (gl.gl_pathv[i]);
    39063946                    elt->next = new;
     
    39123952#endif
    39133953            globfree (&gl);
    3914 #if !defined(KMK) && !defined(NO_ARCHIVES)
     3954#ifndef CONFIG_WITH_ALLOC_CACHES
    39153955            free (old);
    39163956#else
    3917             if (size == sizeof(struct dep))
    3918               free_dep ((struct dep *)old);
    3919             else
    3920               free (old);
     3957            alloccache_free (cache, old);
    39213958#endif
    39223959            break;
Note: See TracChangeset for help on using the changeset viewer.