From 9dee983eebeed295f9be59a009ad94b5dca8934e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 30 Sep 2020 18:00:32 -0700 Subject: [PATCH] remove unused sfreserve() --- lib/sfio/Makefile.am | 2 +- lib/sfio/sfio.h | 5 -- lib/sfio/sfio.vcxproj | 1 - lib/sfio/sfio.vcxproj.filters | 3 - lib/sfio/sfmode.c | 2 +- lib/sfio/sfreserve.c | 148 ---------------------------------- 6 files changed, 2 insertions(+), 159 deletions(-) delete mode 100644 lib/sfio/sfreserve.c diff --git a/lib/sfio/Makefile.am b/lib/sfio/Makefile.am index 9f58bda39..d654e5729 100644 --- a/lib/sfio/Makefile.am +++ b/lib/sfio/Makefile.am @@ -14,7 +14,7 @@ libsfio_C_la_SOURCES = sfclose.c sfcvt.c sfdisc.c \ sfmode.c sfnew.c sfnotify.c \ sfnputc.c sfopen.c sfpkrd.c sfpoll.c sfpool.c \ sfprintf.c sfprints.c sfpurge.c \ - sfputr.c sfraise.c sfrd.c sfread.c sfreserve.c \ + sfputr.c sfraise.c sfrd.c sfread.c \ sfresize.c sfscanf.c sfseek.c sfset.c sfsetbuf.c sfsetfd.c \ sfsize.c sfsk.c sfstack.c sfstrtod.c sfswap.c sfsync.c \ sftable.c sftell.c sftmp.c sfungetc.c sfvprintf.c \ diff --git a/lib/sfio/sfio.h b/lib/sfio/sfio.h index 7af42f856..75dbbc374 100644 --- a/lib/sfio/sfio.h +++ b/lib/sfio/sfio.h @@ -230,10 +230,6 @@ extern "C" { #define SF_BUFCONST 0400000 /* unused flag - for compatibility only */ #endif -/* for sfreserve to hold a record */ -#define SF_LOCKR 0000010 /* lock record, stop access to stream */ -#define SF_LASTR 0000020 /* get the last incomplete record */ - /* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */ #define SF_SEEK 3 /* seek error */ @@ -300,7 +296,6 @@ extern "C" { extern Sfio_t *sfswap(Sfio_t *, Sfio_t *); extern int sfpurge(Sfio_t *); extern int sfpoll(Sfio_t **, int, int); - extern void *sfreserve(Sfio_t *, ssize_t, int); extern int sfsync(Sfio_t *); extern void *sfsetbuf(Sfio_t *, void *, size_t); extern Sfdisc_t *sfdisc(Sfio_t *, Sfdisc_t *); diff --git a/lib/sfio/sfio.vcxproj b/lib/sfio/sfio.vcxproj index 63d9be818..2d0d3253e 100644 --- a/lib/sfio/sfio.vcxproj +++ b/lib/sfio/sfio.vcxproj @@ -111,7 +111,6 @@ - diff --git a/lib/sfio/sfio.vcxproj.filters b/lib/sfio/sfio.vcxproj.filters index 57c34bdfa..6c3f9dcbf 100644 --- a/lib/sfio/sfio.vcxproj.filters +++ b/lib/sfio/sfio.vcxproj.filters @@ -116,9 +116,6 @@ Source Files - - Source Files - Source Files diff --git a/lib/sfio/sfmode.c b/lib/sfio/sfmode.c index b3fd5ff12..bca7187ac 100644 --- a/lib/sfio/sfmode.c +++ b/lib/sfio/sfmode.c @@ -133,7 +133,7 @@ int _sfsetpool(Sfio_t * f) POOLMTXRETURN(p, rv); } -/* create an auxiliary buffer for sfreserve/sfputr */ +/* create an auxiliary buffer for sfputr */ Sfrsrv_t *_sfrsrv(Sfio_t * f, ssize_t size) { Sfrsrv_t *rsrv, *rs; diff --git a/lib/sfio/sfreserve.c b/lib/sfio/sfreserve.c deleted file mode 100644 index 0cc935d75..000000000 --- a/lib/sfio/sfreserve.c +++ /dev/null @@ -1,148 +0,0 @@ -/* $Id$ $Revision$ */ -/* vim:set shiftwidth=4 ts=8: */ - -/************************************************************************* - * Copyright (c) 2011 AT&T Intellectual Property - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: See CVS logs. Details at http://www.graphviz.org/ - *************************************************************************/ - -#include - -/* Reserve a segment of data or buffer. -** -** Written by Kiem-Phong Vo. -*/ - -/** - * @param f file to peek - * @param size size of peek - * @param type LOCKR: lock stream, LASTR: last record - */ -void *sfreserve(Sfio_t * f, ssize_t size, int type) -{ - ssize_t n, sz; - Sfrsrv_t *rsrv; - void *data; - int mode; - - SFMTXSTART(f, NIL(void *)); - - /* initialize io states */ - rsrv = NIL(Sfrsrv_t *); - _Sfi = f->val = -1; - - /* return the last record */ - if (type == SF_LASTR) { - if ((rsrv = f->rsrv) && (n = -rsrv->slen) > 0) { - rsrv->slen = 0; - _Sfi = f->val = n; - SFMTXRETURN(f, (void *) rsrv->data); - } else - SFMTXRETURN(f, NIL(void *)); - } - - if (type > 0 && !(type == SF_LOCKR || type == 1)) - SFMTXRETURN(f, NIL(void *)); - - if ((sz = size) == 0 && type != 0) { /* only return the current status and possibly lock stream */ - if ((f->mode & SF_RDWR) != f->mode && _sfmode(f, 0, 0) < 0) - SFMTXRETURN(f, NIL(void *)); - - SFLOCK(f, 0); - if ((n = f->endb - f->next) < 0) - n = 0; - - if (!f->data && type > 0) - rsrv = _sfrsrv(f, 0); - - goto done; - } - if (sz < 0) - sz = -sz; - - /* iterate until get to a stream that has data or buffer space */ - for (;;) { /* prefer read mode so that data is always valid */ - if (!(mode = (f->flags & SF_READ))) - mode = SF_WRITE; - if ((int) f->mode != mode && _sfmode(f, mode, 0) < 0) { - n = -1; - goto done; - } - - SFLOCK(f, 0); - - if ((n = f->endb - f->next) < 0) /* possible for string+rw */ - n = 0; - - if (n > 0 && n >= sz) /* all done */ - break; - - /* do a buffer refill or flush */ - if (f->mode & SF_WRITE) - (void) SFFLSBUF(f, -1); - else if (type > 0 && f->extent < 0 && (f->flags & SF_SHARE)) { - if (n == 0) { /* peek-read only if there is no buffered data */ - f->mode |= SF_RV; - (void) SFFILBUF(f, sz == 0 ? -1 : (sz - n)); - } - if ((n = f->endb - f->next) < sz) { - if (f->mode & SF_PKRD) { - f->endb = f->endr = f->next; - f->mode &= ~SF_PKRD; - } - goto done; - } - } else - (void) SFFILBUF(f, sz == 0 ? -1 : (sz - n)); - - /* now have data */ - if ((n = f->endb - f->next) > 0) - break; - else if (n < 0) - n = 0; - - /* this test fails only if unstacked to an opposite stream */ - if ((f->mode & mode) != 0) - break; - } - - if (n > 0 && n < sz && (f->mode & mode) != 0) { /* try to accommodate request size */ - if (f->flags & SF_STRING) { - if ((f->mode & SF_WRITE) && (f->flags & SF_MALLOC)) { - (void) SFWR(f, f->next, sz, f->disc); - n = f->endb - f->next; - } - } else if (f->mode & SF_WRITE) { - if (type > 0 && (rsrv = _sfrsrv(f, sz))) - n = sz; - } else { /*if(f->mode&SF_READ) */ - if (type <= 0 && (rsrv = _sfrsrv(f, sz)) && - (n = SFREAD(f, (void *) rsrv->data, sz)) < sz) - rsrv->slen = -n; - } - } - - done: - /* return true buffer size */ - _Sfi = f->val = n; - - SFOPEN(f, 0); - - if ((sz > 0 && n < sz) || (n == 0 && type <= 0)) - SFMTXRETURN(f, NIL(void *)); - - if ((data = rsrv ? (void *) rsrv->data : (void *) f->next)) { - if (type > 0) { - f->mode |= SF_PEEK; - f->endr = f->endw = f->data; - } else if (data == (void *) f->next) - f->next += (size >= 0 ? size : n); - } - - SFMTXRETURN(f, data); -} -- 2.40.0