We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
我两者都用过,而且我绝对更喜欢 util-linux-ng(以前在 e2fsprogs 中)。为了可移植性,我让我的软件支持两者,并使用 autoconf/cmake 宏来检测安装了哪一个。
对我来说,OSSP 的主要问题是它无缘无故地滥用了 C 中的面向对象。 UUID 只是一个 128 位数字,可以用 char[16] 数组表示。 UUID 通常与另一个结构相关联(UUID 用作此类结构的键或标识符),因此如果您可以将该数组内联到结构本身中,那应该会很好。
使用 OSSP UUID,它为您提供一个指向动态分配对象的
uuid_t*
指针,该对象不仅保存 UUID 值,还保存更多状态。如果您处理数以万计的对象,这显然会使程序变慢,使用更多内存并导致更多内存碎片。最后,为了使 OSSP UUID 可用,您必须使用它来生成 UUID(其中涉及 4 个调用:uuid_create、uuid_make、uuid_export 和 uuid_destroy)并自己使用 UUID 值。使用 util-linux-ng,只需一次调用:uuid_generate。I used both, and I definitely prefer the util-linux-ng (formerly in e2fsprogs) one. For portability, I make my software support both and use autoconf/cmake macros to detect which one is installed.
The main problem with OSSP for me is that it abuses object-orientation in C for no good reason. An UUID is just a 128-bit number, which can be represented with a char[16] array. The UUID is usually associated with another structure (the UUID serves as a key or an identifier for such structure), so it should be good if you could inline that array in the structure itself.
With OSSP UUID, it gives you a
uuid_t*
pointer to a dynamically allocated object, which holds more state than just the UUID value. If you work with tens of thousands of objects, this sensibly makes the program slower, uses more memory and causes more memory fragmentation. In the end, to make OSSP UUID usable, you have to use it just to generate the UUID (which involves 4 calls: uuid_create, uuid_make, uuid_export and uuid_destroy) and work with the UUID value yourself. With util-linux-ng, it is just a single call: uuid_generate.