pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:4884:    assert (m->queuepos < mc_wq_used);    assert (m->queuepos * 2 >= mc_wq_used ||    m_la_count >= mc_work_queue[m->queuepos * 2]->la_count);    assert (m->queuepos * 2 + 1 >= mc_wq_used ||    m_la_count >= mc_work_queue[m->queuepos * 2 + 1]->la_count);    pos = m->queuepos;    }       else {    if (mc_wq_used > mc_wq_size) { -  struct mc_marker **p; +  void *p;    mc_wq_size *= 2; -  p = realloc (mc_work_queue + 1, mc_wq_size * sizeof (mc_work_queue[0])); +  /* NB: Add 1 to size to compensate for 1-based indexing. */ +  p = realloc (mc_work_queue, (mc_wq_size + 1) * sizeof (mc_work_queue[0]));    if (!p) { -  make_error (msg_out_of_mem_2, mc_wq_size * sizeof (mc_work_queue[0])); +  make_error (msg_out_of_mem_2, +  (mc_wq_size + 1) * sizeof (mc_work_queue[0]));    free_svalue (&throw_value);    move_svalue (&throw_value, --Pike_sp);    mc_wq_size /= 2;    return;    } -  mc_work_queue = p - 1; /* Compensate for 1-based indexing. */ +  mc_work_queue = p;    }    pos = mc_wq_used++;    }       while (pos > 1 && (n = mc_work_queue[pos / 2])->la_count < m_la_count) {    mc_work_queue[pos] = n;    n->queuepos = pos;    pos /= 2;    }    mc_work_queue[pos] = m;
pike.git/src/gc.c:5600:    }       start_mc();       if (TYPEOF(pike_cycle_depth_str) == PIKE_T_FREE) {    SET_SVAL_TYPE(pike_cycle_depth_str, T_STRING);    MAKE_CONST_STRING (pike_cycle_depth_str.u.string, "pike_cycle_depth");    }       assert (mc_work_queue == NULL); -  mc_work_queue = malloc (MC_WQ_START_SIZE * sizeof (mc_work_queue[0])); +  /* NB: Add 1 to size to compensate for 1-based indexing. */ +  mc_work_queue = malloc ((MC_WQ_START_SIZE + 1) * sizeof (mc_work_queue[0]));    if (!mc_work_queue) {    stop_mc();    SIMPLE_OUT_OF_MEMORY_ERROR ("Pike.count_memory", -  MC_WQ_START_SIZE * sizeof (mc_work_queue[0])); +  (MC_WQ_START_SIZE + 1) * +  sizeof (mc_work_queue[0]));    }    mc_wq_size = MC_WQ_START_SIZE; -  mc_work_queue--; /* Compensate for 1-based indexing. */ +     mc_wq_used = 1;       assert (!mc_pass);    assert (visit_enter == NULL);    assert (visit_ref == NULL);    assert (visit_leave == NULL);       free_svalue (&throw_value);    mark_free_svalue (&throw_value);       {    int i;    for (i = -args + 1; i < 0; i++) {    struct svalue *s = Pike_sp + i;       if (TYPEOF(*s) == T_INT)    continue;       else if (!REFCOUNTED_TYPE(TYPEOF(*s))) { -  mc_work_queue++; /* Compensate for 1-based indexing. */ +     free(mc_work_queue);    mc_work_queue = NULL;    stop_mc();    SIMPLE_ARG_TYPE_ERROR (    "count_memory", i + args + 1,    "array|multiset|mapping|object|program|string|type|int");    }       else {    if (TYPEOF(*s) == T_FUNCTION) {    struct svalue s2;    if (!(s2.u.program = program_from_function (s))) { -  mc_work_queue++; /* Compensate for 1-based indexing. */ +     free(mc_work_queue);    mc_work_queue = NULL;    stop_mc();    SIMPLE_ARG_TYPE_ERROR (    "count_memory", i + args + 1,    "array|multiset|mapping|object|program|string|type|int");    }    add_ref (s2.u.program);    SET_SVAL_TYPE(s2, T_PROGRAM);    free_svalue (s);
pike.git/src/gc.c:5665:    /* The user passed the same thing several times. Ignore it. */    }       else {    struct mc_marker *m =    my_make_mc_marker (s->u.ptr, visit_fn_from_type[TYPEOF(*s)], NULL);    m->flags |= MC_FLAG_INTERNAL;    if (!mc_block_pike_cycle_depth && TYPEOF(*s) == T_OBJECT) {    int cycle_depth = mc_cycle_depth_from_obj (s->u.object);    if (TYPEOF(throw_value) != PIKE_T_FREE) { -  mc_work_queue++; /* Compensate for 1-based indexing. */ +     free(mc_work_queue);    mc_work_queue = NULL;    stop_mc();    throw_severity = THROW_ERROR;    pike_throw();    }    m->la_count = cycle_depth >= 0 ? cycle_depth : mc_lookahead;    }    else    m->la_count = mc_lookahead;
pike.git/src/gc.c:5795:    MC_DEBUG_MSG (NULL, "leave - added to incomplete list");    }    else {    DL_ADD_LAST (mc_complete, mc_ref_from);    MC_DEBUG_MSG (NULL, "leave - added to complete list");    }    }    }       if (TYPEOF(throw_value) != PIKE_T_FREE) { -  mc_work_queue++; /* Compensate for 1-based indexing. */ +     free(mc_work_queue);    mc_work_queue = NULL;    stop_mc();    throw_severity = THROW_ERROR;    pike_throw();    }    }   #if defined (PIKE_DEBUG) || defined (MEMORY_COUNT_DEBUG)    mc_ref_from = (void *) (ptrdiff_t) -1;   #endif
pike.git/src/gc.c:6044:    visit_enter = NULL;    visit_ref = NULL;    visit_leave = NULL;       DL_MAKE_EMPTY (mc_incomplete);    DL_MAKE_EMPTY (mc_indirect);   #ifdef DO_PIKE_CLEANUP   #endif       assert (mc_wq_used == 1); -  mc_work_queue++; /* Compensate for 1-based indexing. */ +     free(mc_work_queue);    mc_work_queue = NULL;    stop_mc();       pop_n_elems (args);    push_ulongest (return_count ? count_internal : mc_counted_bytes);   }      static struct mapping *identify_loop_reverse = NULL;   
pike.git/src/gc.c:6161:    }       start_mc();       if (TYPEOF(pike_cycle_depth_str) == PIKE_T_FREE) {    SET_SVAL_TYPE(pike_cycle_depth_str, T_STRING);    MAKE_CONST_STRING (pike_cycle_depth_str.u.string, "pike_cycle_depth");    }       assert (mc_work_queue == NULL); -  mc_work_queue = malloc (MC_WQ_START_SIZE * sizeof (mc_work_queue[0])); +  /* NB: Add 1 to size to compensate for 1-based indexing. */ +  mc_work_queue = malloc ((MC_WQ_START_SIZE + 1) * sizeof (mc_work_queue[0]));    if (!mc_work_queue) {    stop_mc();    SIMPLE_OUT_OF_MEMORY_ERROR ("Pike.count_memory", -  MC_WQ_START_SIZE * sizeof (mc_work_queue[0])); +  (MC_WQ_START_SIZE + 1) * sizeof (mc_work_queue[0]));    } -  /* NB: 1-based indexing in mc_work_queue. */ -  mc_work_queue--; +     mc_wq_size = MC_WQ_START_SIZE;    mc_wq_used = 1;    mc_lookahead = -1;       assert (!mc_pass);    assert (visit_enter == NULL);    assert (visit_ref == NULL);    assert (visit_leave == NULL);       /* There's a fair chance of there being lots of stuff being referenced,
pike.git/src/gc.c:6205:    if (mc_ref_from->flags & MC_FLAG_INT_VISITED) continue;       mc_ref_from->flags |= MC_FLAG_INT_VISITED;    mc_ref_from->visit_fn(mc_ref_from->thing, VISIT_COMPLEX_ONLY, NULL);    }      #if defined (PIKE_DEBUG) || defined (MEMORY_COUNT_DEBUG)    mc_ref_from = (void *) (ptrdiff_t) -1;   #endif    -  mc_work_queue++; /* Compensate for 1-based indexing. */ +     free(mc_work_queue);    mc_work_queue = NULL;       visit_enter = NULL;    visit_ref = NULL;    visit_leave = NULL;      #ifdef PIKE_DEBUG    if (s != Pike_sp-1) {    Pike_fatal("Stack error in identify_loops.\n");