Ignore:
Timestamp:
Sep 14, 2020, 11:46:32 PM (5 years ago)
Author:
bird
Message:

kash: Use reference counting of parser output in threaded-mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/generated/nodes.c

    r3449 r3458  
    5151#include "shinstance.h"
    5252
     53#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    5354
    5455size_t  funcblocksize;          /* size of structures in function */
     
    9394STATIC char *nodesavestr(char *);
    9495
     96#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    9597
    9698
     
    104106        union node *n;
    105107{
     108#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     109        if (n != NULL) {
     110                unsigned refs = pstackretain(n->pblock);
     111                TRACE2((psh, "copyfunc: %p - %u refs\n", n->pblock, refs)); K_NOREF(refs);
     112        }
     113        return n;
     114#else
    106115        if (n == NULL)
    107116                return NULL;
     
    112121        funcstring = (char *) funcblock + funcblocksize;
    113122        return copynode(n);
    114 }
    115 
    116 
     123#endif
     124}
     125
     126#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    117127
    118128STATIC void
     
    274284      case NAPPEND:
    275285            new->nfile.fname = copynode(n->nfile.fname);
     286            new->nfile.next = copynode(n->nfile.next);
    276287            new->nfile.fd = n->nfile.fd;
    277             new->nfile.next = copynode(n->nfile.next);
    278288            break;
    279289      case NTOFD:
     
    281291            new->ndup.vname = copynode(n->ndup.vname);
    282292            new->ndup.dupfd = n->ndup.dupfd;
     293            new->ndup.next = copynode(n->ndup.next);
    283294            new->ndup.fd = n->ndup.fd;
    284             new->ndup.next = copynode(n->ndup.next);
    285295            break;
    286296      case NHERE:
    287297      case NXHERE:
    288298            new->nhere.doc = copynode(n->nhere.doc);
     299            new->nhere.next = copynode(n->nhere.next);
    289300            new->nhere.fd = n->nhere.fd;
    290             new->nhere.next = copynode(n->nhere.next);
    291301            break;
    292302      case NNOT:
     
    335345}
    336346
     347#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    337348
    338349
     
    343354void
    344355freefunc(psh, n)
    345     shinstance *psh;
     356        shinstance *psh;
    346357        union node *n;
    347358{
     359#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     360        if (n)
     361                pstackrelease(psh, n->pblock, "freefunc");
     362#else
    348363        if (n)
    349364                ckfree(psh, n);
    350 }
     365#endif
     366}
Note: See TracChangeset for help on using the changeset viewer.