[DGD]string reference/swapout problems
Marc Spoorendonk
marc at freud.et.tudelft.nl
Sat Mar 6 16:42:24 CET 1999
On Fri, 5 Mar 1999, Felix A. Croes wrote:
> Marc Spoorendonk <marc at freud.et.tudelft.nl> wrote:
>
> >[...]
> > I have attempted to code a really simple piece of code: A global errstr
> > string which can be shown to the coder when a function returns an error
> > state.
> >
> > What I want is:
> > void set_errstr(string error_string); // stores a string into the driver
> > string get_errstr(); // retrieves the string
> >
> > Ofcourse this can be done with a str_new() but i thought that it should be
> > possible to store just a pointer to the string in the driver. (see the
> > paste of the source code) This works fine but when i force a swapout, the
> > string gets swapped out and we get stuck with a string pointer which
> > points into unknown space.
> >
> > My question is: Is there a way to prevent the string from being swapped
> > out?
>
> You can prevent swapping altogether in the config file by setting both
> swap_fragment and static_chunk to 0, and masking swapout() in the
> auto object. That is the only way to prevent LPC datatypes, such as
> strings, from being swapped out.
That has ofcourse nothing to do with my problem. Swapping is cool, I don't
want to shut it off. The question is: Can i store a string in the driver
by reference. Or do i always need to copy it due to swapout problems
otherwise?
>
>
> > And the general question: When do i need to str_ref() or str_del() when
> > using strings in kfuns?
>
> str_ref(): whenever a pointer starts to point to a string.
> str_del(): whenever a pointer that points to a string is assigned a
> new value, or becomes invalid. In particular, if a
> string is popped from the runtime stack, the pointer on
> the stack becomes invalid and therefore str_del() has to
> be used.
Ah, Thanx for this info.
>
> Regards,
> Dworkin
>
> List config page: http://list.imaginary.com/mailman/listinfo/dgd
>
Regards,
Marc
--
Marc Spoorendonk
Department of Electrical Engineering
Delft University of Technology
e-mail : Marc at freud.et.tudelft.nl
mud : telnet://freud.et.tudelft.nl:8888
URL : http://freud.et.tudelft.nl/~marc/index.html
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list