From: "boyd, rounin" <boyd@insultant.net>
To: <9fans@cse.psu.edu>
Subject: Re: [9fans] Rstat needs three size fields?
Date: Tue, 8 Jul 2003 22:41:39 +0200 [thread overview]
Message-ID: <008601c34591$54e87200$d2944251@insultant.net> (raw)
In-Reply-To: <3F0B273E.30201@proweb.co.uk>
> yes, tis true, but only temporarily
tis true it's a god-awful algorithm.
mangle the pointer from char * to void * in this:
typedef long msg_idx;
typedef struct
{
msg_idx v_count;
msg_idx v_size;
msg_idx v_incr;
char **v_list;
}
vec;
echo vec.c
sed 's/.//' >vec.c <<'//GO.SYSIN DD vec.c'
-/*
- * Dynamic vector of strings.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)vec.c 1.31";
-#endif lint
-
-#include "mace.h"
-
-void
-vec_init(v, n)
-register vec *v;
-register int n;
-{
- v->v_count = 0;
- v->v_size = v->v_incr = n;
- v->v_list = (char **)salloc(n * sizeof(char *));
-}
-
-char *
-vec_str(v, s)
-register vec *v;
-register char *s;
-{
- if (v->v_count == v->v_size)
- v->v_list = (char **)srealloc((char *)v->v_list, (int)(v->v_size +=
v->v_incr) * sizeof(char *));
-
- v->v_list[v->v_count++] = s;
-
- return s;
-}
-
-char *
-vec_cat(v, s)
-register vec *v;
-register char *s;
-{
- if (v->v_count != 0)
- {
- register char *p;
-
- if (v->v_list[v->v_count - 1] != NULLSTR)
- {
- p = concat(v->v_list[v->v_count - 1], s);
-
- (void)free(v->v_list[v->v_count - 1]);
- (void)free(s);
- }
- else
- p = s;
-
- return v->v_list[v->v_count - 1] = p;
- }
- else
- return vec_str(v, s);
-}
-
-void
-vec_free(v)
-register vec *v;
-{
- register int i;
-
- for (i = 0; i < v->v_count; i++)
- {
- if (v->v_list[i] != NULLSTR)
- (void)free(v->v_list[i]);
- }
-
- v->v_count = 0;
- v->v_size = 0;
- v->v_incr = 0;
- (void)free((char *)v->v_list);
-}
//GO.SYSIN DD vec.c
i think that demonstrates the concept.
next prev parent reply other threads:[~2003-07-08 20:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-30 18:04 Sam
2003-06-30 19:08 ` ron minnich
2003-06-30 19:15 ` boyd, rounin
2003-07-04 3:18 ` Russ Cox
2003-07-04 15:04 ` Sam
2003-07-04 17:13 ` rob pike, esq.
2003-07-07 8:33 ` Douglas A. Gwyn
2003-07-07 9:03 ` Geoff Collyer
2003-07-07 15:10 ` Douglas A. Gwyn
2003-07-08 0:49 ` ron minnich
2003-07-07 15:50 ` rob pike, esq.
2003-07-07 20:38 ` boyd, rounin
2003-07-07 21:18 ` rog
2003-07-07 21:28 ` boyd, rounin
2003-07-07 23:23 ` [9fans] simple, sufficient rog
2003-07-07 20:54 ` [9fans] Rstat needs three size fields? Geoff Collyer
2003-07-09 2:07 ` William Josephson
2003-07-07 15:48 ` rob pike, esq.
2003-07-07 15:58 ` Jack Johnson
2003-07-08 8:32 ` Douglas A. Gwyn
2003-07-08 10:30 ` boyd, rounin
2003-07-08 11:09 ` matt
2003-07-08 11:36 ` Dan Cross
2003-07-08 12:12 ` boyd, rounin
2003-07-08 14:14 ` ron minnich
2003-07-08 17:42 ` chris
2003-07-08 20:19 ` matt
2003-07-08 20:41 ` boyd, rounin [this message]
2003-07-09 14:58 ` rog
2003-07-09 19:42 ` boyd, rounin
2003-07-10 12:30 ` rog
2003-07-08 22:09 ` ron minnich
2003-07-08 22:19 ` Dan Cross
2003-07-09 1:27 ` ron minnich
2003-07-01 21:46 boyd, rounin
2003-07-02 0:24 boyd, rounin
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='008601c34591$54e87200$d2944251@insultant.net' \
--to=boyd@insultant.net \
--cc=9fans@cse.psu.edu \
/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).