There was a typo in my example..
But Ross Berteig gave a more clear explanation than this example.
On Tue, Jun 02, 2015 at 02:49:42PM -0400, Martin Gagnon wrote:
>
>
> But here, if I'm not mistaken the problem was more like:
> ----------------------------------------------------------
>
> char *g_foo[2] = {NULL, NULL};
>
> char *g_bar[2] = {"hello", "world"};
>
> void foo(char *p)
> {
> g_foo[0] = p[0]; // this point to "azView"
> g_foo[1] = p[1]; // this point to "azView"
~~~^~~~ : Here should be g_bar
> }
>
> void foo2()
> {
> // do something with g_foo, which point to azView, which may not exist
> // anymore.
> }
>
> void func(void)
> {
> if (<some condition>) {
> char *azView[2];
> azView[0] = g_bar[0];
> azView[1] = g_bar[1];
>
> foo(azView);
> }
>
> foo2(); // use g_foo which point to inexistent azView
> }
--
Martin G.
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users