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/nodes.c.pat

    r2391 r3458  
    4747#include "shinstance.h"
    4848
     49#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    4950
    5051size_t  funcblocksize;          /* size of structures in function */
     
    6263STATIC char *nodesavestr(char *);
    6364
     65#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    6466
    6567
     
    7375        union node *n;
    7476{
     77#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     78        if (n != NULL) {
     79                unsigned refs = pstackretain(n->pblock);
     80                TRACE2((psh, "copyfunc: %p - %u refs\n", n->pblock, refs)); K_NOREF(refs);
     81        }
     82        return n;
     83#else
    7584        if (n == NULL)
    7685                return NULL;
     
    8190        funcstring = (char *) funcblock + funcblocksize;
    8291        return copynode(n);
     92#endif
    8393}
    8494
    85 
     95#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    8696
    8797STATIC void
     
    154164}
    155165
     166#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    156167
    157168
     
    165176        union node *n;
    166177{
     178#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     179        if (n)
     180                pstackrelease(psh, n->pblock, "freefunc");
     181#else
    167182        if (n)
    168183                ckfree(psh, n);
     184#endif
    169185}
Note: See TracChangeset for help on using the changeset viewer.