diff options
Diffstat (limited to '')
-rw-r--r-- | common/membuf.h (renamed from util/memrchr.c) | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/util/memrchr.c b/common/membuf.h index 5621f7323..9033be61e 100644 --- a/util/memrchr.c +++ b/common/membuf.h @@ -1,5 +1,5 @@ -/* memrchr.c - libc replacement function - * Copyright (C) 2005 Free Software Foundation, Inc. +/* membuf.h - A simple implementation of a dynamic buffer + * Copyright (C) 2001, 2003 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -19,31 +19,24 @@ * USA. */ -/* - memrchr() is a GNU function that might not be available everywhere. - It's basically the inverse of memchr() - search backwards in a - memory block for a particular character. -*/ +#ifndef GNUPG_COMMON_MEMBUF_H +#define GNUPG_COMMON_MEMBUF_H -#include <config.h> -#include <string.h> +/* The definition of the structure is private, we only need it here, + so it can be allocated on the stack. */ +struct private_membuf_s { + size_t len; + size_t size; + char *buf; + int out_of_core; +}; -/* There are many ways to optimize this, but this is a simple - unoptimized implementation. */ -void * -memrchr(const void *s, int c, size_t n) -{ - const unsigned char *start=s,*end=s; +typedef struct private_membuf_s membuf_t; - end+=n-1; - while(end>=start) - { - if(*end==c) - return (void *)end; - else - end--; - } +void init_membuf (membuf_t *mb, int initiallen); +void put_membuf (membuf_t *mb, const void *buf, size_t len); +void *get_membuf (membuf_t *mb, size_t *len); - return NULL; -} + +#endif /*GNUPG_COMMON_MEMBUF_H*/ |