[asterisk-dev] Re: [asterisk-commits] russell: trunk r48930 - in /trunk: ./ configs/ include/asterisk/ main/

Luigi Rizzo rizzo at icir.org
Sat Dec 23 18:13:03 MST 2006


On Sat, Dec 23, 2006 at 08:13:15PM -0000, asterisk-commits at lists.digium.com wrote:
> Author: russell
> Date: Sat Dec 23 14:13:14 2006
> New Revision: 48930
> 
> URL: http://svn.digium.com/view/asterisk?view=rev&rev=48930
> Log:
> - Convert the list of URI handlers to use the linked list macros.  While doing
>   this, implementing locking of this list to make it thread-safe.
> 
> - Add a "redirect" option to http.conf that allows redirecting one URI to
>   another.  I was inspired to do this while playing with the Asterisk GUI.  I
>   got tired of typing this URL to get to the GUI:

nice one, but what's the point of going through string fields for
this one, given that the strings are written only once and their
size is known at the time of allocation ?

I'd rather define the struct as done other times in these cases i.e.

	struct http_uri_redirect {
		struct http_uri_redirect *next;
		char *dest;
		char target[0];
	}

and allocate it as

	struct http_uri_redirect *s;

	int l1 = strlen(target) + 1;
	int l = sizeof(*s) + l1 + strlen(dest) + 1;

	s = ast_calloc(l);
	s->dest = s->target + l1;
	strcpy(s->target, target);
	strcpy(s->dest, dest);

cheers
luigi


More information about the asterisk-dev mailing list