summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2002-06-26 21:03:28 +0000
committerMarcus Boerger <helly@php.net>2002-06-26 21:03:28 +0000
commitd96924ffc5828b544e6d2ead3e492700618659b8 (patch)
tree725cf9595176db1745b6452245f2bda899b30c1e /main
parentd812929d2f46c93a7c77cf86bcc0db1a6c293e59 (diff)
downloadphp-git-d96924ffc5828b544e6d2ead3e492700618659b8.tar.gz
-xbuf_resize does not need to have return value
Diffstat (limited to 'main')
-rw-r--r--main/spprintf.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/main/spprintf.c b/main/spprintf.c
index de7efc3978..fe34b12002 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -118,16 +118,15 @@ typedef struct xbuf_area xbuffy;
/* Resize xbuf so that add bytes can be added. Reallocation is done
* in defined block size to minimize calls to realloc.
*/
-static int xbuf_resize(xbuffy *xbuf, size_t add)
+static void xbuf_resize(xbuffy *xbuf, size_t add)
{
char *buf;
- int ret;
size_t size, offset;
if (xbuf->buf) {
offset = xbuf->nextb - xbuf->buf;
if (offset+add < xbuf->size) {
- return 0; /* do not change size if not necessary */
+ return; /* do not change size if not necessary */
}
} else {
offset = 0;
@@ -139,32 +138,27 @@ static int xbuf_resize(xbuffy *xbuf, size_t add)
}
if (xbuf->max_len && size > xbuf->max_len) {
size = xbuf->max_len;
- ret = 1;
- } else {
- ret = 0;
}
-
+
buf = erealloc(xbuf->buf, size+1); /* alloc space for NUL */
- if (!buf) {
- return 1;
- } else {
+ if (buf) {
xbuf->buf = buf;
xbuf->buf_end = xbuf->max_len ? &buf[size] : (char *) ~0;
xbuf->nextb = buf+offset;
xbuf->size = size;
- return ret;
}
}
/* Initialise xbuffy with size spprintf_BLOCK_SIZE
*/
-static int xbuf_init(xbuffy *xbuf, size_t max_len)
+static char * xbuf_init(xbuffy *xbuf, size_t max_len)
{
xbuf->buf = NULL;
xbuf->size = 0;
xbuf->max_len = max_len;
- return xbuf_resize(xbuf, 0); /* NOT max_len */
+ xbuf_resize(xbuf, 0); /* NOT max_len */
+ return xbuf->buf;
}
/*
@@ -617,7 +611,7 @@ PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap
* Notice that if no length is given, we initialize buf_end to the
* highest possible address.
*/
- if (xbuf_init(&xbuf, max_len)) {
+ if (!xbuf_init(&xbuf, max_len)) {
if (pbuf)
*pbuf = NULL;
return 0;