Example #1
0
/* Free a thc.
 *
 * You must hold the thc_mutex before calling this function.
 */
static void thc_cluster_free(tcp_helper_cluster_t* thc)
{
  int i;
  tcp_helper_cluster_t *thc_walk, *thc_prev;

  thc_uninstall_tproxy(thc);

  /* Free up resources within the thc */
  for( i = 0; i < CI_CFG_MAX_REGISTER_INTERFACES; ++i )
    if( thc->thc_vi_set[i] != NULL )
      efrm_vi_set_release(thc->thc_vi_set[i]);

  ci_assert(ci_dllist_is_empty(&thc->thc_tlos));

  /* Remove from the thc_head list */
  thc_walk = thc_head;
  thc_prev = NULL;
  while( thc_walk != NULL ) {
    if( thc_walk == thc ) {
      if( thc_walk == thc_head ) {
        ci_assert_equal(thc_prev, NULL);
        thc_head = thc_walk->thc_next;
      }
      else {
        thc_prev->thc_next = thc_walk->thc_next;
      }
      kfree(thc_walk);
      return;
    }
    thc_prev = thc_walk;
    thc_walk = thc_walk->thc_next;
  }
  ci_assert(0);
}
Example #2
0
int ci_buddy_alloc(ci_buddy_allocator* b, unsigned order)
{
  unsigned smallest;
  ci_dllink* l;
  unsigned addr;

  ci_buddy_assert_valid(b);

  /* Find smallest chunk that is big enough.  ?? Can optimise this by
  ** keeping array of pointers to smallest chunk for each order.
  */
  smallest = order;
  while( smallest <= b->order && ci_dllist_is_empty(FL(b, smallest)) )
    ++smallest;

  if( smallest > b->order ) {
    DEBUG_ALLOC(ci_log("buddy - alloc order %d failed - max order %d",
                       order, b->order););