[exim] Returning static strings from dlfunc?

Pàgina inicial
Delete this message
Reply to this message
Autor: Janne Snabb
Data:  
A: exim-users
Assumpte: [exim] Returning static strings from dlfunc?
Hi all,

I am writing my first dlfunc. My question is: Is it ok to return a
pointer to a static string? I could not find answer to this in the
documentation.

Consider the following example:

#include "local_scan.h"

int foobar(uschar **yield, int argc, uschar *argv[])
{
        *yield = US"foobar";
        return OK;
}


Is the above correct, or should I write the following instead?

    *yield = string_copy(US"foobar");


The first version seems to work fine, but when looking at dlfuncs
written by other people I often see the second alternative which makes a
copy of the original string. Why?

Best Regards,
--
Janne Snabb / EPIPE Communications
snabb@??? - http://epipe.com/