t_status set_reserve_pipe(t_options options, t_size datasz, i_set* id) { o_set o; /* * 0) */ if (datasz < sizeof (t_id)) CORE_ESCAPE("unable to reserve a set for objects smaller than " "an identifier"); if (id == NULL) CORE_ESCAPE("the 'id' argument is null"); if (options & SET_OPTION_CONTAINER) CORE_ESCAPE("this type of set cannot be used as a container"); if (options & SET_OPTION_ORGANISE) CORE_ESCAPE("this type of set does not support the organise option"); if ((options & SET_OPTION_ALLOCATE) && (options & SET_OPTION_FREE)) CORE_ESCAPE("unable to reserve a set with both alloc and free options"); /* * 1) */ if (id_reserve(&_set.id, id) != STATUS_OK) CORE_ESCAPE("unable to reserve the set identifier"); /* * 2) */ memset(&o, 0x0, sizeof (o_set)); o.id = *id; o.size = 0; o.type = SET_TYPE_PIPE; o.options = options; o.datasz = datasz; o.u.ll.head = NULL; o.u.ll.tail = NULL; /* * 3) */ if (set_new(&o) != STATUS_OK) CORE_ESCAPE("unable to register the set descriptor"); CORE_LEAVE(); }
t_error set_reserve_pipe(t_opts opts, t_size datasz, i_set* setid) { o_set o; SET_ENTER(set); /* * 1) */ memset(&o, 0x0, sizeof(o_set)); /* * 2) */ if (opts & SET_OPT_ORGANISE) SET_LEAVE(set, ERROR_UNKNOWN); if ((opts & SET_OPT_ALLOC) && (opts & SET_OPT_FREE)) SET_LEAVE(set, ERROR_UNKNOWN); /* * 3) */ if (opts & SET_OPT_CONTAINER) { *setid = set->sets; } else { if (id_reserve(&set->id, setid) != ERROR_NONE) SET_LEAVE(set, ERROR_UNKNOWN); } /* * 4) */ o.setid = *setid; o.size = 0; o.type = SET_TYPE_PIPE; o.opts = opts; o.datasz = datasz; o.u.ll.head = NULL; o.u.ll.tail = NULL; /* * 5) */ if (set_new(&o) != ERROR_NONE) { if (!(opts & SET_OPT_CONTAINER)) id_release(&set->id, o.setid); SET_LEAVE(set, ERROR_UNKNOWN); } SET_LEAVE(set, ERROR_NONE); }