示例#1
0
static chunk_t *chunk_add(const chunk_t *pc_in, chunk_t *ref, const loc_t pos)
{
   chunk_t *pc = chunk_dup(pc_in);

   if (pc != NULL)
   {
      if (ref != NULL) /* ref is a valid chunk */
      {
         (pos == AFTER) ? g_cl.AddAfter(pc, ref) : g_cl.AddBefore(pc, ref);
      }
      else /* ref == NULL */
      {
         (pos == AFTER) ? g_cl.AddHead(pc) : g_cl.AddTail(pc);
      }
      chunk_log(pc, "chunk_add");
   }
   return(pc);
}
示例#2
0
/**
 * Add a copy before the given chunk.
 * If ref is NULL, add at the head.
 */
chunk_t *chunk_add_before(const chunk_t *pc_in, chunk_t *ref)
{
   chunk_t *pc;

   if ((pc = chunk_dup(pc_in)) != NULL)
   {
      if (ref != NULL)
      {
         g_cl.AddBefore(pc, ref);
      }
      else
      {
         g_cl.AddTail(pc);
      }
      chunk_log(pc, "chunk_add");
   }
   return(pc);
}
示例#3
0
static chunk_t *chunk_add(const chunk_t *pc_in, chunk_t *ref, const direction_e pos)
{
   chunk_t *pc = chunk_dup(pc_in);

   if (pc != nullptr)
   {
      if (ref != nullptr) // ref is a valid chunk
      {
         (pos == direction_e::FORWARD) ? g_cl.AddAfter(pc, ref) : g_cl.AddBefore(pc, ref);
      }
      else // ref == NULL
      {
         (pos == direction_e::FORWARD) ? g_cl.AddHead(pc) : g_cl.AddTail(pc);
      }
      chunk_log(pc, "chunk_add");
   }
   return(pc);
}
示例#4
0
/**
 * Add a copy after the given chunk.
 * If ref is NULL, add at the head.
 */
chunk_t *chunk_add_after(const chunk_t *pc_in, chunk_t *ref)
{
   chunk_t *pc;

   if ((pc = chunk_dup(pc_in)) != NULL)
   {
      if (ref != NULL)
      {
         g_cl.AddAfter(pc, ref);
      }
      else
      {
         g_cl.AddHead(pc);
      }
      chunk_log(pc, "chunk_add");
   }
   return(pc);
}
示例#5
0
void chunk_del(chunk_t *pc)
{
   chunk_log(pc, "chunk_del");
   g_cl.Pop(pc);
   delete pc;
}