24 #ifdef CONF_BUNDLE_NUM
25 #define BUNDLE_NUM CONF_BUNDLE_NUM
27 #define BUNDLE_NUM (BUNDLE_STORAGE_SIZE + 10)
30 #define INIT_GUARD() \
33 memset(bundleslots, 0, sizeof(bundleslots));\
38 static uint8_t inited = 0;
39 static struct bundle_slot_t bundleslots[BUNDLE_NUM];
40 static uint8_t slots_in_use = 0;
43 struct bundle_slot_t *bundleslot_get_free()
48 for (i=0; i<BUNDLE_NUM; i++) {
49 if (bundleslots[i].ref == 0) {
50 memset(&bundleslots[i], 0,
sizeof(
struct bundle_slot_t));
53 bundleslots[i].type = 0;
56 return &bundleslots[i];
63 void bundleslot_free(
struct bundle_slot_t *bs)
65 if( bs->bundle.ptr ==
NULL ) {
66 LOG(LOGD_DTN, LOG_SLOTS, LOGL_ERR,
"DUPLICATE FREE");
73 LOG(LOGD_DTN, LOG_SLOTS, LOGL_DBG,
"bundleslot_free(%p) %u", bs, slots_in_use);
76 memset(bs->bundle.ptr, 0,
sizeof(
struct bundle_t));
81 bs->bundle.ptr =
NULL;
85 int bundleslot_increment(
struct bundle_slot_t *bs)
87 LOG(LOGD_DTN, LOG_SLOTS, LOGL_DBG,
"bundleslot_inc(%p) to %u", bs, bs->ref+1);
97 int bundleslot_decrement(
struct bundle_slot_t *bs)
99 LOG(LOGD_DTN, LOG_SLOTS, LOGL_DBG,
"bundleslot_dec(%p) to %u", bs, bs->ref-1);