On Sun, 09 Sep 2007 02:37:18 +0200, Pierre Habouzit wrote:Some string APIs don't store the size, some include the bytes in the "struct" itself using the struct hack, in C. For instance ustr uses 3 bytes more than strdup(), by default, for "small" strings[1] -- which includes a size, length, reference counting and a "memory failure occured" error. On the other extreme, C++ strings or Vstr take up much more than 12/24[2] bytes (because they are designed to be used differently) and strbuf itself takes up 16/20[2] bytes. Note that I'm not saying you shouldn't use a decent string API, quite the opposite, but assuming that "whatever is embedded in the language" is good enough for all purposes is far from reality. [1] 1-255 bytes is "small", for obvious reasons you need one more byte after that (note that "", 0 byte strings, don't take any bytes to store with ustr). [2] 32bit/64bit sizes -- James Antill -- james@and.org C String APIs use too much memory? ustr: length, ref count, size and read-only/fixed. Ave. 44% overhead over strdup(), for 0-20B strings http://www.and.org/ustr/ - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| James Bottomley | Re: Integration of SCST in the mainstream Linux kernel |
| Rafael J. Wysocki | 2.6.27-rc4-git1: Reported regressions from 2.6.26 |
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
| Greg Kroah-Hartman | [PATCH 016/196] kref: add kref_set() |
git: | |
| Peter Zijlstra | Re: [PATCH 3/3] Convert the UDP hash lock to RCU |
| Frans Pop | svc: failed to register lockdv1 RPC service (errno 97). |
| Gerrit Renker | [PATCH 03/37] dccp: List management for new feature negotiation |
| David Miller | Re: [GIT]: Networking |
