예제 #1
0
파일: list.c 프로젝트: 54madao/Mobile-C
void ListClearCB(list_p list, ListElemDestroyFunc_t cb)
{
  void* data;
  while( (data = ListPop(list)) != NULL) {
    cb(data);
  }
}
예제 #2
0
파일: t_list.cpp 프로젝트: huokedu/ardb
 int Ardb::BRPop(Context& ctx, RedisCommandFrame& cmd)
 {
     uint32 timeout;
     if (!string_touint32(cmd.GetArguments()[cmd.GetArguments().size() - 1], timeout))
     {
         fill_error_reply(ctx.reply, "timeout is not an integer or out of range");
         return 0;
     }
     for (uint32 i = 0; i < cmd.GetArguments().size() - 1; i++)
     {
         if (ListPop(ctx, cmd.GetArguments()[i], false) == 0 && ctx.reply.type == REDIS_REPLY_STRING)
         {
             RedisReply& r1 = ctx.reply.AddMember();
             RedisReply& r2 = ctx.reply.AddMember();
             fill_str_reply(r1, cmd.GetArguments()[i]);
             fill_str_reply(r2, ctx.reply.str);
             return 0;
         }
     }
     for (uint32 i = 0; i < cmd.GetArguments().size() - 1; i++)
     {
         AddBlockKey(ctx, cmd.GetArguments()[i]);
     }
     if (NULL != ctx.client)
     {
         ctx.client->DetachFD();
         if (timeout > 0)
         {
             ctx.block->blocking_timer_task_id = ctx.client->GetService().GetTimer().ScheduleHeapTask(
                     new BlockConnectionTimeout(&ctx), timeout, -1, SECONDS);
         }
     }
     return 0;
 }
예제 #3
0
파일: t_list.cpp 프로젝트: huokedu/ardb
 int Ardb::RPopLPush(Context& ctx, RedisCommandFrame& cmd)
 {
     std::string v;
     if (ListPop(ctx, cmd.GetArguments()[0], false) == 0 && ctx.reply.type == REDIS_REPLY_STRING)
     {
         std::string value = ctx.reply.str;
         ListInsert(ctx, cmd.GetArguments()[1], NULL, ctx.reply.str, false, false);
         fill_str_reply(ctx.reply, value);
     }
     else
     {
         ctx.reply.type = REDIS_REPLY_NIL;
     }
     return 0;
 }
예제 #4
0
파일: bsptree.c 프로젝트: NautiluX/geomview
static void BSPTreeCreateRecursive(BSPTreeNode *tree,
				   PolyListNode *pllist,
#if BSPTREE_STATS
				   int depth,
#endif
				   struct obstack *scratch)
{
  PolyListNode *plnode, *front, *back;
  EdgeIntersection edges[2];

  tree->front = tree->back = NULL;
  ListPop(pllist, plnode);
  tree->polylist = plnode;
  check_poly(plnode->poly);
  PolyPlane(plnode, &tree->plane);

  front = back = NULL;
  while (pllist) {    
    ListPop(pllist, plnode);
    check_poly(plnode->poly);
    switch (ClassifyPoly(&tree->plane, plnode->poly, edges)) {
    case BACKOF:
      check_poly(plnode->poly);
      ListPush(back, plnode);
      break;
    case COPLANAR:
      check_poly(plnode->poly);
      ListPush(tree->polylist, plnode);
      break;
    case INFRONTOF:
      check_poly(plnode->poly);
      ListPush(front, plnode);
      break;
    case BOTH_SIDES:
      check_poly(plnode->poly);
      SplitPolyNode(plnode, &front, &back, edges, scratch);
      break;
    }
  }
  if (front) {
    tree->front = obstack_alloc(scratch, sizeof(*tree->front));
    BSPTreeCreateRecursive(tree->front, front,
#if BSPTREE_STATS
			   depth+1,
#endif
			   scratch);
  }
  if (back) {
    tree->back = obstack_alloc(scratch, sizeof(*tree->back));
    BSPTreeCreateRecursive(tree->back, back,
#if BSPTREE_STATS
			   depth+1,
#endif
			   scratch);
  }
#if BSPTREE_STATS
  if (depth > tree_depth) {
    tree_depth = depth;
  }
#endif
}
예제 #5
0
파일: t_list.cpp 프로젝트: huokedu/ardb
 int Ardb::LPop(Context& ctx, RedisCommandFrame& cmd)
 {
     return ListPop(ctx, cmd.GetArguments()[0], true);
 }