From 54c0937433709a59e4206ca10dfb02aecbc1a3ee Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 11 Feb 2009 16:27:51 +0000 Subject: [PATCH] Thu Jan 8 12:08:14 CST 2009 Pekka Pessi * memspn.c, memcspn.c: use functions from git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11785 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/libsofia-sip-ua/su/memcspn.c | 47 +++------------------ libs/sofia-sip/libsofia-sip-ua/su/memspn.c | 40 +++--------------- 3 files changed, 11 insertions(+), 78 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index f5e0782a05..7538a81de9 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Wed Feb 11 10:23:36 CST 2009 +Wed Feb 11 10:27:42 CST 2009 diff --git a/libs/sofia-sip/libsofia-sip-ua/su/memcspn.c b/libs/sofia-sip/libsofia-sip-ua/su/memcspn.c index c873210ed2..22424c0455 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/memcspn.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/memcspn.c @@ -32,50 +32,13 @@ #include "config.h" -#include -#include +#include + +size_t memcspn(const void *mem, size_t memlen, + const void *reject, size_t rejectlen); -/**Search memory for bytes not in a given set. - * - * The memcspn() function calculates the length of the memory area @a mem - * which consists entirely of bytes not in @a reject. - * - * @param mem pointer to memory area - * @param memlen size of @a mem in bytes - * @param reject pointer to table containing bytes to reject - * @param rejectlen size of @a reject table - * - * @return - * The memspn() function returns the number of bytes in the memory area @a - * which consists entirely of bytes not in @a reject. - * @par - * If @a rejectlen is 0, or @a reject is NULL, it returns @a memlen, size of - * the memory area. - */ size_t memcspn(const void *mem, size_t memlen, const void *reject, size_t rejectlen) { - size_t i; - - unsigned char const *m = mem, *r = reject; - - char rejected[UCHAR_MAX + 1]; - - if (rejectlen == 0 || reject == 0) - return memlen; - - if (mem == NULL || memlen == 0) - return 0; - - memset(rejected, 0, sizeof rejected); - - for (i = 0; i < rejectlen; i++) - rejected[r[i]] = 1; - - for (i = 0; i < memlen; i++) - if (rejected[m[i]]) - break; - - return i; + return su_memcspn(mem, memlen, reject, rejectlen); } - diff --git a/libs/sofia-sip/libsofia-sip-ua/su/memspn.c b/libs/sofia-sip/libsofia-sip-ua/su/memspn.c index 952ab4f055..a49c5c4b79 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/memspn.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/memspn.c @@ -34,43 +34,13 @@ #include "config.h" -#include -#include +#include + +size_t memspn(const void *mem, size_t memlen, + const void *accept, size_t acceptlen); -/**Scan memory for a set of bytes. - * - * The memspn() function calculates the length of the memory area @a mem - * which consists entirely of bytes in @a accept. - * - * @param mem pointer to memory area - * @param memlen size of @a mem in bytes - * @param accept pointer to table containing bytes to accept - * @param acceptlen size of @a accept table - * - * @return - * The memspn() function returns the number of bbytes in the memory area @a - * which consists entirely of bytes in @a accept. - */ size_t memspn(const void *mem, size_t memlen, const void *accept, size_t acceptlen) { - size_t i; - - unsigned char const *m = mem, *a = accept; - - char accepted[UCHAR_MAX + 1]; - - if (mem == NULL || memlen == 0 || acceptlen == 0 || accept == NULL) - return 0; - - memset(accepted, 0, sizeof accepted); - - for (i = 0; i < acceptlen; i++) - accepted[a[i]] = 1; - - for (i = 0; i < memlen; i++) - if (!accepted[m[i]]) - break; - - return i; + return su_memspn(mem, memlen, accept, acceptlen); }