+static struct cake_fl*
+__alloc_fl(piece_t prev_id, piece_t max_len) {
+ unsigned int i, j;
+ struct cake_fl* cake_fl;
+
+ cake_fl = cake_grab(&fl_pile);
+ for (i = 0, j=prev_id; i < CAKE_FL_MAXLEN && j < max_len; i++, j++)
+ {
+ cake_fl->indices[i] = j + 1;
+ }
+
+ for (i -= 1; j == max_len && i < CAKE_FL_SIZE; i++) {
+ cake_fl->indices[i] = EO_FREE_PIECE;
+ }
+
+ cake_fl->next = NULL;
+ return cake_fl;
+}
+
+static void
+__free_fls(struct cake_s* cake) {
+ unsigned int i, j;
+ struct cake_fl *cake_fl, *next;
+
+ cake_fl = cake->fl;
+ while (cake_fl)
+ {
+ next = cake_fl->next;
+ cake_release(&fl_pile, cake_fl);
+ cake_fl = next;
+ }
+
+ cake->fl = NULL;
+}
+
+static piece_t*
+__fl_slot(struct cake_s* cake, piece_t index)
+{
+ int id_acc;
+ struct cake_fl* cake_fl;
+ struct cake_pile* pile;
+
+ pile = cake->owner;
+ if (embedded_pile(pile)) {
+ return &cake->free_list[index];
+ }
+
+ id_acc = 0;
+ cake_fl = cake->fl;
+ while (index >= CAKE_FL_MAXLEN)
+ {
+ index -= CAKE_FL_MAXLEN;
+ id_acc += CAKE_FL_MAXLEN;
+
+ if (cake_fl->next) {
+ cake_fl = cake_fl->next;
+ continue;
+ }
+
+ cake_fl = __alloc_fl(id_acc, pile->pieces_per_cake);
+ cake_fl->next = cake_fl;
+ }
+
+ return &cake_fl->indices[index];
+}
+
+static inline struct cake_s*
+__create_cake_extern(struct cake_pile* pile)