[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation o
From: |
Paul Eggert |
Subject: |
Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows |
Date: |
19 Nov 2003 12:44:19 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
James Youngman <address@hidden> writes:
> I normally use void* to discourage the user from fiddling with my
> data.
You can prevent the user from fiddling with your data with struct, if
you put something like this in your .h file:
struct foo;
int access_function (struct foo *p);
and then put something like this in the corresponding .c file:
struct foo { int x; }
int access_function (struct foo *p) { return p->x; }
The advantage of this approach (as opposed to void *) is the improved
type-checking: you catch more dumb mistakes (e.g.,
access_function("oops")) at compile-time.
You can combine this idea with the typedef idea, e.g., by putting this
in your header:
struct foo;
typedef struct foo *foo;
int access_function (foo p);
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, (continued)
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Simon Josefsson, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Bruno Haible, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Simon Josefsson, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Simon Josefsson, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, James Youngman, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows,
Paul Eggert <=
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Bruno Haible, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Simon Josefsson, 2003/11/19