std::vector<char *> foo;
void func(int argc, VALUE * argv, VALUE self) {
foo.push_back(STR2CSTR(argv[0]));
rb_global_variable(&argv[0]);
}
can i see more of this?
So my question is: why does rb_gc_register_address() store VALUE*'s
instead of VALUE’s? I suppose that if it stored a VALUE, then it would
be possible to register an object as a global but not keep a reference
to that object; this may not be desirable. In our case, though, we just
wanted the string to remain valid.
i’m not positive, but if you did not store pointers to pointers to objects,
you would not be able to change, in the gc, what that pointerer was pointing
to! you would only be able to change the thing pointed to itself! eg. the gc
would never be able to set an object pointer to nil, or anywhere else…
the difference is illustrated here :
#include <stdlib.h>
#include <stdio.h>
void
i_can_change_what_memory_you_point_to (ptr)
char **ptr;
{
*ptr = “barfoo”;
}
void
i_can_change_the_memory_you_point_to (ptr)
char *ptr;
{
*ptr = ‘b’;
}
int
main (int argc, char **argv, char **env)
{
char *buf = malloc(42);
char *ptr;
ptr = buf;
strcpy (ptr, "foobar");
printf("%s\n", ptr); /* -->> "foobar" */
i_can_change_what_memory_you_point_to (&ptr);
printf("%s\n", ptr); /* -->> "barfoo" */
ptr = buf;
strcpy (ptr, "foo");
printf("%s\n", ptr); /* -->> "foo" */
i_can_change_the_memory_you_point_to (ptr);
printf("%s\n", ptr); /* -->> "boo" */
return 0;
}
the gc must have a prototype like ‘i_can_change_what_memory_you_point_to’
If I do have a bug like this in the future, what techniques can I use to
track it down?
gcc has built in memory leak debugging - but it only works with c. a good
reason not to use c++ imo. 
i actually have a modification, somewhere, which works with c++, want it?
-a
···
On Tue, 22 Oct 2002, Paul Brannan wrote:
–
====================================
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================