diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-10-08 08:13:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:39 -0500 |
commit | 7d32679e9683c81aca538f0267684332a28a286f (patch) | |
tree | 445aecfad24e8dab1fe7a200904a712212fa7091 /source4/lib/registry/reg_backend_nt4 | |
parent | 48f960ab47707ca24898834da4da440d1f7fb0d9 (diff) | |
download | samba-7d32679e9683c81aca538f0267684332a28a286f.tar.gz samba-7d32679e9683c81aca538f0267684332a28a286f.tar.bz2 samba-7d32679e9683c81aca538f0267684332a28a286f.zip |
r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associated functions.
The motivation for this change was to avoid having to convert to/from
ucs2 strings for so many operations. Doing that was slow, used many
static buffers, and was also incorrect as it didn't cope properly with
unicode codepoints above 65536 (which could not be represented
correctly as smb_ucs2_t chars)
The two core functions that allowed this change are next_codepoint()
and push_codepoint(). These functions allow you to correctly walk a
arbitrary multi-byte string a character at a time without converting
the whole string to ucs2.
While doing this cleanup I also fixed several ucs2 string handling
bugs. See the commit for details.
The following code (which counts the number of occuraces of 'c' in a
string) shows how to use the new interface:
size_t count_chars(const char *s, char c)
{
size_t count = 0;
while (*s) {
size_t size;
codepoint_t c2 = next_codepoint(s, &size);
if (c2 == c) count++;
s += size;
}
return count;
}
(This used to be commit 814881f0e50019196b3aa9fbe4aeadbb98172040)
Diffstat (limited to 'source4/lib/registry/reg_backend_nt4')
-rw-r--r-- | source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c index c271c55991..14fff5b60d 100644 --- a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c +++ b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c @@ -1029,7 +1029,7 @@ static WERROR nk_to_key(TALLOC_CTX *mem_ctx, struct registry_hive *h, NK_HDR *nk uint_t nk_id; SK_HDR *sk_hdr; int type; - char key_name[1024], cls_name[1024]; + char key_name[1024]; if (!nk_hdr) return WERR_INVALID_PARAM; @@ -1086,16 +1086,16 @@ static WERROR nk_to_key(TALLOC_CTX *mem_ctx, struct registry_hive *h, NK_HDR *nk */ if (clsname_len) { /* Just print in Ascii for now */ - smb_ucs2_t *clsnamep; + void *clsnamep; int clsnam_off; clsnam_off = IVAL(&nk_hdr->clsnam_off,0); - clsnamep = (smb_ucs2_t *)LOCN(regf->base, clsnam_off); + clsnamep = LOCN(regf->base, clsnam_off); DEBUG(2, ("Class Name Offset: %0X\n", clsnam_off)); pull_ucs2_talloc(mem_ctx, &tmp->class_name, clsnamep); - DEBUGADD(2,(" Class Name: %s\n", cls_name)); + DEBUGADD(2,(" Class Name: %s\n", tmp->class_name)); } |