From: cinap_lenrek@felloff.net
To: 9front@9front.org
Subject: Re: [9front] fix ref822
Date: Fri, 22 Nov 2019 08:21:54 +0100 [thread overview]
Message-ID: <4F2E28EFD56B89BE598EA209856361F5@felloff.net> (raw)
In-Reply-To: 3538A24A05D19F1D333569AA901FA1E4@eigenstate.org
i think this is also wrong:
+ if(i + n > Nref){
+ for(i = 0; i < n; i++)
+ free(a[i]);
+ for(i = n; i < Nref; i++)
+ a[i - n] = a[i];
}
i is number of entries in a[], n is number of entries in f[]. if we got
like i = 1 and n = Nref, we'd want to remove 1 item from a because:
i + n - Nref == 1 + Nref - Nref == 1
also, i think the uniqarray() approach is wrong. we probably want to
deduplicate while we insert into a. we should never populate m->references
with duplicate items in the first place.
delete uniquearray() and instead just do it like this:
a = m->references;
n = tokenize(f, ....);
for(i=0; i<n; i++){
for(j=0; j<Nref; j++){
if(a[j] == nil || strcmp(a[j], f[i]) == 0)
break;
}
if(j == Nref){
// handle full case, shift a by one
}
// now a[j] can be: nil = slot free,
a[j] = f[i]; // put into array
}
--
cinap
next reply other threads:[~2019-11-22 7:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 7:21 cinap_lenrek [this message]
2019-11-22 17:59 ori
2019-11-22 18:39 ori
2019-11-22 21:14 cinap_lenrek
2019-11-22 21:24 ori
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=4F2E28EFD56B89BE598EA209856361F5@felloff.net \
--to=cinap_lenrek@felloff.net \
--cc=9front@9front.org \
/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).