Sha256: 0d1410a5cf4f4fececda3c265daec180bf86084c13b7d822087e2620cefad3c1
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
/* Copyright (C) 2005-2011 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com> Please see the LICENSE file for copyright and distribution information */ #include "rp_stack.h" #define INITIAL_STACK_SIZE 8 /* Creates a stack of prof_frame_t to keep track of timings for active methods. */ prof_stack_t * stack_create() { prof_stack_t *stack = ALLOC(prof_stack_t); stack->start = ALLOC_N(prof_frame_t, INITIAL_STACK_SIZE); stack->ptr = stack->start; stack->end = stack->start + INITIAL_STACK_SIZE; return stack; } void stack_free(prof_stack_t *stack) { xfree(stack->start); xfree(stack); } prof_frame_t * stack_push(prof_stack_t *stack) { /* Is there space on the stack? If not, double its size. */ if (stack->ptr == stack->end ) { size_t len = stack->ptr - stack->start; size_t new_capacity = (stack->end - stack->start) * 2; REALLOC_N(stack->start, prof_frame_t, new_capacity); stack->ptr = stack->start + len; stack->end = stack->start + new_capacity; } return stack->ptr++; } prof_frame_t * stack_pop(prof_stack_t *stack) { if (stack->ptr == stack->start) return NULL; else return --stack->ptr; } prof_frame_t * stack_peek(prof_stack_t *stack) { if (stack->ptr == stack->start) return NULL; else return stack->ptr - 1; }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-prof-0.11.0.rc1-x86-mingw32 | ext/ruby_prof/rp_stack.c |
ruby-prof-0.11.0.rc1 | ext/ruby_prof/rp_stack.c |