From 05669c67a751b6e5a11ad88ee78978788d7e4b00 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 19 Apr 2022 20:51:58 -0700 Subject: [PATCH] sfio: remove unused 'sfresize' Gitlab: #1998 --- ci/clang_format.py | 1 - lib/sfio/CMakeLists.txt | 1 - lib/sfio/Makefile.am | 2 +- lib/sfio/sfio.h | 1 - lib/sfio/sfio.vcxproj | 1 - lib/sfio/sfio.vcxproj.filters | 3 -- lib/sfio/sfresize.c | 63 ----------------------------------- 7 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 lib/sfio/sfresize.c diff --git a/ci/clang_format.py b/ci/clang_format.py index e4a3cead1..bc24c5236 100644 --- a/ci/clang_format.py +++ b/ci/clang_format.py @@ -670,7 +670,6 @@ EXCLUDE = ( "lib/sfio/sfraise.c", "lib/sfio/sfrd.c", "lib/sfio/sfread.c", - "lib/sfio/sfresize.c", "lib/sfio/sfscanf.c", "lib/sfio/sfseek.c", "lib/sfio/sfsetbuf.c", diff --git a/lib/sfio/CMakeLists.txt b/lib/sfio/CMakeLists.txt index e968f641d..0d5379703 100644 --- a/lib/sfio/CMakeLists.txt +++ b/lib/sfio/CMakeLists.txt @@ -22,7 +22,6 @@ add_library(sfio STATIC sfraise.c sfrd.c sfread.c - sfresize.c sfscanf.c sfseek.c sfsetbuf.c diff --git a/lib/sfio/Makefile.am b/lib/sfio/Makefile.am index b2763c302..3579caa1e 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 \ sfnputc.c sfopen.c sfpkrd.c \ sfprintf.c \ sfputr.c sfraise.c sfrd.c sfread.c \ - sfresize.c sfscanf.c sfseek.c sfsetbuf.c sfsetfd.c \ + sfscanf.c sfseek.c sfsetbuf.c sfsetfd.c \ sfsk.c sfstack.c sfswap.c sfsync.c \ sftable.c sftmp.c sfungetc.c sfvprintf.c \ sfvscanf.c sfwr.c sfwrite.c diff --git a/lib/sfio/sfio.h b/lib/sfio/sfio.h index b9e38f01c..b5bf21d57 100644 --- a/lib/sfio/sfio.h +++ b/lib/sfio/sfio.h @@ -213,7 +213,6 @@ extern "C" { extern int sfsscanf(const char *, const char *, ...); extern int sfvsscanf(const char *, const char *, va_list); extern int sfvscanf(Sfio_t *, const char *, va_list); - extern int sfresize(Sfio_t *, Sfoff_t); /* io functions with discipline continuation */ extern ssize_t sfrd(Sfio_t *, void *, size_t, Sfdisc_t *); diff --git a/lib/sfio/sfio.vcxproj b/lib/sfio/sfio.vcxproj index 3c288273c..ea364cdd7 100644 --- a/lib/sfio/sfio.vcxproj +++ b/lib/sfio/sfio.vcxproj @@ -101,7 +101,6 @@ - diff --git a/lib/sfio/sfio.vcxproj.filters b/lib/sfio/sfio.vcxproj.filters index ec2056861..e72a65ab7 100644 --- a/lib/sfio/sfio.vcxproj.filters +++ b/lib/sfio/sfio.vcxproj.filters @@ -89,9 +89,6 @@ Source Files - - Source Files - Source Files diff --git a/lib/sfio/sfresize.c b/lib/sfio/sfresize.c deleted file mode 100644 index 2950a9900..000000000 --- a/lib/sfio/sfresize.c +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************* - * 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: Details at https://graphviz.org - *************************************************************************/ - -#include - -/* Resize a stream. - Written by Kiem-Phong Vo. -*/ - -int sfresize(Sfio_t * f, Sfoff_t size) -{ - SFMTXSTART(f, -1); - - if (size < 0 || f->extent < 0 || - (f->mode != SF_WRITE && _sfmode(f, SF_WRITE, 0) < 0)) - SFMTXRETURN(f, -1); - - SFLOCK(f, 0); - - if (f->flags & SF_STRING) { - SFSTRSIZE(f); - - if (f->extent >= size) { - if ((f->flags & SF_MALLOC) && (f->next - f->data) <= size) { - size_t s = (((size_t) size + 1023) / 1024) * 1024; - void *d; - if (s < f->size && (d = realloc(f->data, s))) { - f->data = d; - f->size = s; - f->extent = s; - } - } - memclear((char *) (f->data + size), (int) (f->extent - size)); - } else { - if (SFSK(f, size, SEEK_SET, f->disc) != size) - SFMTXRETURN(f, -1); - memclear((char *) (f->data + f->extent), - (int) (size - f->extent)); - } - } else { - if (f->next > f->data) - SFSYNC(f); -#ifdef HAVE_FTRUNCATE - if (ftruncate(f->file, size) < 0) - SFMTXRETURN(f, -1); -#else - SFMTXRETURN(f, -1); -#endif - } - - f->extent = size; - - SFOPEN(f, 0); - - SFMTXRETURN(f, 0); -} -- 2.40.0