From: richard@inf.ed.ac.uk (Richard Tobin)
Subject: [TUHS] Future Languages
Date: Tue, 5 Sep 2017 15:41:55 +0100 (BST) [thread overview]
Message-ID: <20170905144155.4A625150E352@macaroni.inf.ed.ac.uk> (raw)
In-Reply-To: Larry McVoy's message of Mon, 4 Sep 2017 14:59:24 -0700
> So we have some source (that you can have as well, Apache license)
> that handles not strings but vectors of strings (or structs or whatever).
>
> I need to write up how it works, it's sort of clever. It stores both
> the size of the vector (always a power of 2) in part of the bits of the
> first entry and the actual length in the other part. Because we can
> express powers of two in very little space we can support both values
> in a 32 bit unsigned with a max length of used space of around 134M.
I have something similar. It allocates space for two ints (number
allocated and used) at ((int *)array)[-1] and [-2].
Typical use is
LTVectorAndInit(char *, names);
while(...)
LTVectorPush(names, s);
for(i=0; i<LTVectorCount(names); i++)
... names[i] ...;
LTVectorFree(names);
-- Richard
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
next reply other threads:[~2017-09-05 14:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 14:41 Richard Tobin [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-09-03 14:48 [TUHS] Why Pascal is Not My Favorite Programming Language - Unearthed! Norman Wilson
2017-09-04 21:28 ` [TUHS] Future Languages Steve Johnson
2017-09-04 21:59 ` Larry McVoy
2017-09-05 2:21 ` Noel Hunt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170905144155.4A625150E352@macaroni.inf.ed.ac.uk \
--to=richard@inf.ed.ac.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).