ib_status_t DLL_PUBLIC ib_cfgparser_block_pop(ib_cfgparser_t *cp, const char **pname) { IB_FTRACE_INIT(ib_cfgparser_block_pop); ib_engine_t *ib = cp->ib; const char *name; ib_status_t rc; if (pname != NULL) { *pname = NULL; } rc = ib_list_pop(cp->block, &name); if (rc != IB_OK) { ib_log_error(ib, 4, "Failed to pop block: %d", rc); cp->cur_blkname = NULL; IB_FTRACE_RET_STATUS(rc); } if (pname != NULL) { *pname = name; } /* The last in the list is now the current. */ cp->cur_blkname = (const char *)ib_list_node_data(ib_list_last(cp->block)); IB_FTRACE_RET_STATUS(IB_OK); }
ib_status_t ib_cfgparser_context_pop(ib_cfgparser_t *cp, ib_context_t **pctx) { IB_FTRACE_INIT(ib_cfgparser_context_pop); ib_engine_t *ib = cp->ib; ib_context_t *ctx; ib_status_t rc; if (pctx != NULL) { *pctx = NULL; } /* Remove the last item. */ rc = ib_list_pop(cp->stack, &ctx); if (rc != IB_OK) { ib_log_error(ib, 4, "Failed to pop context: %d", rc); IB_FTRACE_RET_STATUS(rc); } if (pctx != NULL) { *pctx = ctx; } /* The last in the list is now the current. */ ctx = (ib_context_t *)ib_list_node_data(ib_list_last(cp->stack)); cfgp_set_current(cp, ctx); ib_log_debug(ib, 9, "Stack: ctx=%p site=%p(%s) loc=%p(%s)", cp->cur_ctx, cp->cur_site, cp->cur_site?cp->cur_site->name:"NONE", cp->cur_loc, cp->cur_loc?cp->cur_loc->path:"/"); IB_FTRACE_RET_STATUS(IB_OK); }
//! Pop last element off list. void pop_back() const { Internal::throw_if_error(ib_list_pop(m_ib, NULL)); }
//! Pop last element off list. void pop_back() const { throw_if_error(ib_list_pop(m_ib, NULL)); }
/// @test Test util list library - ib_list_push() and ib_list_pop() TEST_F(TestIBUtilList, test_list_push_and_pop) { ib_list_t *list; ib_status_t rc; int v0 = 0; int v1 = 1; int v2 = 2; int v3 = 3; int v4 = 4; int *val; rc = ib_list_create(&list, MemPool()); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(list); ASSERT_EQ(0UL, ib_list_elements(list)); /* Pop invalid. */ rc = ib_list_pop(list,(void *)&val); ASSERT_EQ(IB_ENOENT, rc); ASSERT_FALSE(val); ASSERT_EQ(0UL, ib_list_elements(list)); /* Simple pushes followed by pops. */ rc = ib_list_push(list, &v0); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(1UL, ib_list_elements(list)); rc = ib_list_push(list, &v1); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(2UL, ib_list_elements(list)); rc = ib_list_push(list, &v2); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(3UL, ib_list_elements(list)); rc = ib_list_push(list, &v3); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(4UL, ib_list_elements(list)); rc = ib_list_push(list, &v4); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(5UL, ib_list_elements(list)); ASSERT_EQ(v0, *(int *)(ib_list_node_data(ib_list_first(list)))); ASSERT_EQ(v4, *(int *)(ib_list_node_data(ib_list_last(list)))); rc = ib_list_pop(list, (void *)&val); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(val); ASSERT_EQ(v4, *val); ASSERT_EQ(4UL, ib_list_elements(list)); rc = ib_list_pop(list, (void *)&val); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(val); ASSERT_EQ(v3, *val); ASSERT_EQ(3UL, ib_list_elements(list)); rc = ib_list_pop(list, (void *)&val); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(val); ASSERT_EQ(v2, *val); ASSERT_EQ(2UL, ib_list_elements(list)); rc = ib_list_pop(list, (void *)&val); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(val); ASSERT_EQ(v1, *val); ASSERT_EQ(1UL, ib_list_elements(list)); rc = ib_list_pop(list, (void *)&val); ASSERT_EQ(IB_OK, rc); ASSERT_TRUE(val); ASSERT_EQ(v0, *val); ASSERT_EQ(0UL, ib_list_elements(list)); }