int main() { struct m_stack stack; int i = 0; int j = 0; assert(m_stack_init(&stack) == 0); for(i = 1; m_stack_push(&stack, i) == 0; i++) { } assert(i > 1); assert(m_stack_empty(&stack) == 0); printf("stack full %d \n", i); i -= 1; while((j = m_stack_pop(&stack)) != 0) { assert(j == i); i--; printf("j %d \n", j); } assert(i == 0); assert(m_stack_empty(&stack) == 1); m_stack_clean(&stack); return 0; }
void pdf_dev_clear_gstates (void) { pdf_gstate *gs; if (m_stack_depth(&gs_stack) > 1) /* at least 1 elem. */ WARN("GS stack depth is not zero at the end of the document."); while ((gs = m_stack_pop(&gs_stack)) != NULL) { clear_a_gstate(gs); RELEASE(gs); } return; }
int pdf_dev_pop_gstate (void) { m_stack *gss = &gs_stack; pdf_gstate *gs; if (m_stack_depth(gss) <= 1) { /* Initial state at bottom */ WARN("Too many grestores."); return -1; } gs = m_stack_pop(gss); clear_a_gstate(gs); RELEASE(gs); return 0; }
int pdf_dev_grestore (void) { pdf_gstate *gs; if (m_stack_depth(&gs_stack) <= 1) { /* Initial state at bottom */ WARN("Too many grestores."); return -1; } gs = m_stack_pop(&gs_stack); clear_a_gstate(gs); RELEASE(gs); pdf_doc_add_page_content(" Q", 2); /* op: Q */ pdf_dev_reset_fonts(); return 0; }
void pdf_dev_grestore_to (int depth) { m_stack *gss = &gs_stack; pdf_gstate *gs; ASSERT(depth >= 0); if (m_stack_depth(gss) > depth + 1) { WARN("Closing pending transformations at end of page/XObject."); } while (m_stack_depth(gss) > depth + 1) { pdf_doc_add_page_content(" Q", 2); /* op: Q */ gs = m_stack_pop(gss); clear_a_gstate(gs); RELEASE(gs); } pdf_dev_reset_fonts(); return; }