1 /* ucl_str.c -- string functions for the the UCL library
3 This file is part of the UCL data compression library.
5 Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
8 The UCL library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The UCL library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the UCL library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/ucl/
37 /***********************************************************************
38 // slow but portable <string.h> stuff, only used in assertions
39 ************************************************************************/
42 ucl_memcmp(const ucl_voidp s1
, const ucl_voidp s2
, ucl_uint len
)
44 #if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCMP)
45 return memcmp(s1
,s2
,len
);
47 const ucl_byte
*p1
= (const ucl_byte
*) s1
;
48 const ucl_byte
*p2
= (const ucl_byte
*) s2
;
66 ucl_memcpy(ucl_voidp dest
, const ucl_voidp src
, ucl_uint len
)
68 #if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCPY)
69 return memcpy(dest
,src
,len
);
71 ucl_byte
*p1
= (ucl_byte
*) dest
;
72 const ucl_byte
*p2
= (const ucl_byte
*) src
;
74 if (len
<= 0 || p1
== p2
)
85 ucl_memmove(ucl_voidp dest
, const ucl_voidp src
, ucl_uint len
)
87 #if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMMOVE)
88 return memmove(dest
,src
,len
);
90 ucl_byte
*p1
= (ucl_byte
*) dest
;
91 const ucl_byte
*p2
= (const ucl_byte
*) src
;
93 if (len
<= 0 || p1
== p2
)
115 UCL_PUBLIC(ucl_voidp
)
116 ucl_memset(ucl_voidp s
, int c
, ucl_uint len
)
118 #if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET)
119 return memset(s
,c
,len
);
121 ucl_byte
*p
= (ucl_byte
*) s
;