home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:18485 comp.std.c:3218
- Path: sparky!uunet!tdat!tools3!swf
- From: swf@tools3teradata.com (Stan Friesen)
- Newsgroups: comp.lang.c,comp.std.c
- Subject: Re: Is this ANSI: final (long)
- Message-ID: <1623@tdat.teradata.COM>
- Date: 16 Dec 92 19:19:33 GMT
- References: <Zc15uB4w165w@quest.UUCP> <723773123.1323@hitech.com.au> <alien.01ss@acheron.amigans.gen.nz> <Bz3n1I.73o@unx.sas.com> <1363@mwtech.UUCP>
- Sender: news@tdat.teradata.COM
- Distribution: world
- Organization: NCR Teradata Database Business Unit
- Lines: 30
-
- In article <1363@mwtech.UUCP>, martin@mwtech.UUCP (Martin Weitzel) writes:
- |> In article <Bz3n1I.73o@unx.sas.com> sasghm@theseus.unx.sas.com (Gary Merrill) writes:
- |> :In article <alien.01ss@acheron.amigans.gen.nz>, alien@acheron.amigans.gen.nz (Ross Smith) writes:
- |> :|>
- |> :|> ... Why not just
- |> :|> use a pointer instead of kludging it up with a fake array?
- |> :|> [example deleted]
- |> :
- |> :The point is this: If you are dynamically allocating *both* the
- |> :structure and the data, the approach you suggest requires *two*
- |> :separate allocations (and two separate frees if you will be freeing
- |> :the stuff). ...
- |>
- |> Yes, and there's another point: With a single allocation you may
- |> memcpy/memmove/memcmp/[f]read/[f]write the whole easily. ...
-
- Of course you could solve both problems by using the solution we came up with here:
-
- struct data {
- char *dptr
- ...
- };
-
- struct data *dp = malloc(sizeof(struct data) + strlen(string));
- dp->dptr = (char *)dp + sizeof(struct data);
-
- --
- sarima@teradata.com (formerly tdatirv!sarima)
- or
- Stanley.Friesen@ElSegundoCA.ncr.com
-