UTF-8 and LDAP

Juergen Hasch Hasch at t-online.de
Fri Mar 1 14:29:02 GMT 2002


Am Freitag, 1. März 2002 02:13 schrieb Andrew Bartlett:
> Can you look at doing these without using fstrings all over the place?
> We are trying (slowly, painfully) to move to allocated buffers.  We have
> some 'convert and allocate' functions that might do what you want - or
> you could add a convert and talloc() version if that makes it easier.
>

Now this is somehow more a political issue than an implementation problem.
I can use talloc() at some locations where a TALLOC_CTX is already available, 
but in other cases it seems more straightforward to use malloc() like this:

	utf8_field=malloc(2*strlen(field));
	push_utf8(utf8_field,field,2*strlen(field));
	...
	SAFE_FREE(utf8_field);

Alternatively I can do:

	utf8_field=push_utf8_allocate(field);
	...
	SAFE_FREE(utf8_field);
	
Using something like this:
char *push_utf8_allocate(const char *src)
{
	int src_len = strlen(src);
	char *pb;
	
	pb = malloc(2*src_len);
	if (pb==NULL)
		return -1;
	push_utf8(pb, src, 2*src_len, STR_TERMINATE);
	return realloc(pb,strlen(pb));
}

Any comments ?
...Juergen





More information about the samba-technical mailing list