git.samba.org
/
samba.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a7d4a6d
)
Added Andrew Bartlett's patch to use an allocated buffer for count_chars.
author
Jeremy Allison
<jra@samba.org>
Fri, 13 Feb 2004 22:06:23 +0000
(22:06 +0000)
committer
Jeremy Allison
<jra@samba.org>
Fri, 13 Feb 2004 22:06:23 +0000
(22:06 +0000)
Jeremy.
source/lib/util_str.c
patch
|
blob
|
history
diff --git
a/source/lib/util_str.c
b/source/lib/util_str.c
index 2d1f596c97922e49da0fb8a89d52ae60532ac502..cde6b2e7a1728fadeb127efea896d3f886f610c0 100644
(file)
--- a/
source/lib/util_str.c
+++ b/
source/lib/util_str.c
@@
-557,10
+557,16
@@
size_t count_chars(const char *s,char c)
{
smb_ucs2_t *ptr;
int count;
- push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE);
- for(count=0,ptr=tmpbuf;*ptr;ptr++)
+ smb_ucs2_t *alloc_tmpbuf;
+
+ if (push_ucs2_allocate(&alloc_tmpbuf, s) == (size_t)-1) {
+ return 0;
+ }
+
+ for(count=0,ptr=alloc_tmpbuf;*ptr;ptr++)
if(*ptr==UCS2_CHAR(c))
count++;
+
return(count);
}