diff --git a/CHANGES.md b/CHANGES.md index 7023a4c..2ed842c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,10 +7,13 @@ v1.0.0 (TBD) - Added `pdfioFileCreateOutput` API to support streaming output of PDF (Issue #21) +- Fixed `all-shared` target (Issue #22) +- Fixed memory leaks (Issue #23) +- Updated `pdfioContentSetDashPattern` to accept `double` values (Issue #25) - Fixed some issues identified by a Coverity scan. v1.0b1 (August 30, 2021) ------------------------ -- Initial release \ No newline at end of file +- Initial release diff --git a/Makefile b/Makefile index 9369fa2..4934c24 100644 --- a/Makefile +++ b/Makefile @@ -75,8 +75,8 @@ all: $(TARGETS) all-shared: if test `uname` = Darwin; then \ $(MAKE) DSONAME="libpdfio.1.dylib" -$(MAKEFLAGS) all; \ - else - $(MAKE) DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \ + else \ + $(MAKE) COMMONFLAGS="-g -Os -fPIC" DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \ fi debug: @@ -124,6 +124,9 @@ install-shared: test: testpdfio ./testpdfio +valgrind: testpdfio + valgrind --leak-check=full ./testpdfio + # pdfio library libpdfio.a: $(LIBOBJS) @@ -131,7 +134,7 @@ libpdfio.a: $(LIBOBJS) $(RANLIB) $@ libpdfio.so.1: $(LIBOBJS) - $(CC) $(DSOFLAGS) $(COMMONFLAGS) -shared -o $@ -Wl,soname,$@ $(LIBOBJS) $(LIBS) + $(CC) $(DSOFLAGS) $(COMMONFLAGS) -shared -o $@ -Wl,-soname,$@ $(LIBOBJS) $(LIBS) libpdfio.1.dylib: $(LIBOBJS) $(CC) $(DSOFLAGS) $(COMMONFLAGS) -dynamiclib -o $@ -install_name $(prefix)/lib/$@ -current_version $(VERSION) -compatibility_version 1.0 $(LIBOBJS) $(LIBS) diff --git a/doc/pdfio.3 b/doc/pdfio.3 index af77926..25e7fc0 100644 --- a/doc/pdfio.3 +++ b/doc/pdfio.3 @@ -1,4 +1,4 @@ -.TH pdfio 3 "pdf read/write library" "2021-09-27" "pdf read/write library" +.TH pdfio 3 "pdf read/write library" "2021-10-18" "pdf read/write library" .SH NAME pdfio \- pdf read/write library .SH Introduction @@ -152,7 +152,7 @@ There is also an Xcode project ("pdfio.xcodeproj") you can use on macOS which ge You can reproduce this with the makefile using: .nf - sudo make 'COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64"' install + sudo make COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64" install .fi .SS Detecting PDFio .PP @@ -160,7 +160,7 @@ PDFio can be detected using the pkg\-config command, for example: .nf if pkg\-config \-\-exists pdfio; then - ... + ... fi .fi .PP @@ -1406,9 +1406,9 @@ Set the stroke pattern. .nf bool pdfioContentSetDashPattern ( pdfio_stream_t *st, - int phase, - int on, - int off + double phase, + double on, + double off ); .fi .SS pdfioContentSetFillColorDeviceCMYK diff --git a/doc/pdfio.html b/doc/pdfio.html index 84a484a..b32cfd7 100644 --- a/doc/pdfio.html +++ b/doc/pdfio.html @@ -548,12 +548,12 @@ make install-shared
sudo xcodebuild install
You can reproduce this with the makefile using:
-sudo make 'COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64"' install
+sudo make COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64" install
Detecting PDFio
PDFio can be detected using the pkg-config
command, for example:
if pkg-config --exists pdfio; then
- ...
+ ...
fi
In a makefile you can add the necessary compiler and linker options with:
@@ -1563,7 +1563,7 @@ bool pdfioContentSave(pdfio_stream_t *st);
pdfioContentSetDashPattern
Set the stroke pattern.
-bool pdfioContentSetDashPattern(pdfio_stream_t *st, int phase, int on, int off);
+bool pdfioContentSetDashPattern(pdfio_stream_t *st, double phase, double on, double off);
Parameters
st
diff --git a/pdfio-array.c b/pdfio-array.c
index ae97a9c..4196ec8 100644
--- a/pdfio-array.c
+++ b/pdfio-array.c
@@ -357,6 +357,15 @@ _pdfioArrayDebug(pdfio_array_t *a, // I - Array
void
_pdfioArrayDelete(pdfio_array_t *a) // I - Array
{
+ size_t i; // Looping var
+
+
+ for (i = 0; i < a->num_values; i ++)
+ {
+ if (a->values[i].type == PDFIO_VALTYPE_BINARY)
+ free(a->values[i].value.binary.data);
+ }
+
if (a)
free(a->values);
diff --git a/pdfio-content.c b/pdfio-content.c
index c020960..0d27241 100644
--- a/pdfio-content.c
+++ b/pdfio-content.c
@@ -660,11 +660,11 @@ pdfioContentSave(pdfio_stream_t *st) // I - Stream
bool // O - `true` on success, `false` on failure
pdfioContentSetDashPattern(
pdfio_stream_t *st, // I - Stream
- int phase, // I - Phase (offset within pattern)
- int on, // I - On length
- int off) // I - Off length
+ double phase, // I - Phase (offset within pattern)
+ double on, // I - On length
+ double off) // I - Off length
{
- return (pdfioStreamPrintf(st, "[%d %d] %d d\n", on, off, phase));
+ return (pdfioStreamPrintf(st, "[%g %g] %g d\n", on, off, phase));
}
diff --git a/pdfio-content.h b/pdfio-content.h
index 004b620..412b62f 100644
--- a/pdfio-content.h
+++ b/pdfio-content.h
@@ -96,7 +96,7 @@ extern bool pdfioContentPathMoveTo(pdfio_stream_t *st, double x, double y) _PDF
extern bool pdfioContentPathRect(pdfio_stream_t *st, double x, double y, double width, double height) _PDFIO_PUBLIC;
extern bool pdfioContentRestore(pdfio_stream_t *st) _PDFIO_PUBLIC;
extern bool pdfioContentSave(pdfio_stream_t *st) _PDFIO_PUBLIC;
-extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, int phase, int on, int off) _PDFIO_PUBLIC;
+extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, double phase, double on, double off) _PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) _PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g) _PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) _PDFIO_PUBLIC;
diff --git a/pdfio-stream.c b/pdfio-stream.c
index f22f892..1cd56e7 100644
--- a/pdfio-stream.c
+++ b/pdfio-stream.c
@@ -114,6 +114,8 @@ pdfioStreamClose(pdfio_stream_t *st) // I - Stream
goto done;
}
}
+
+ deflateEnd(&st->flate);
}
else if (st->crypto_cb && st->bufptr > st->buffer)
{
diff --git a/testpdfio.c b/testpdfio.c
index 3db591f..300ffa3 100644
--- a/testpdfio.c
+++ b/testpdfio.c
@@ -979,7 +979,7 @@ do_unit_tests(void)
puts("\n");
}
else
- return (1);
+ goto fail;
// Test the value parsers for edge cases...
fputs("_pdfioValueRead(cid_dict): ", stdout);
@@ -993,7 +993,7 @@ do_unit_tests(void)
puts("\n");
}
else
- return (1);
+ goto fail;
// Do crypto tests...
if (do_crypto_tests())
@@ -1004,34 +1004,36 @@ do_unit_tests(void)
if ((outpdf = pdfioFileCreate("testpdfio-out.pdf", NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
puts("PASS");
else
- return (1);
+ goto fail;
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
- return (1);
+ goto fail;
if (read_unit_file("testpdfio-out.pdf", num_pages, first_image, false))
- return (1);
+ goto fail;
// Stream a new PDF file...
if ((outfd = open("testpdfio-out2.pdf", O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0)
{
perror("Unable to open \"testpdfio-out2.pdf\"");
- return (1);
+ goto fail;
}
fputs("pdfioFileCreateOutput(...): ", stdout);
if ((outpdf = pdfioFileCreateOutput((pdfio_output_cb_t)output_cb, &outfd, NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
puts("PASS");
else
- return (1);
+ goto fail;
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
- return (1);
+ goto fail;
close(outfd);
if (read_unit_file("testpdfio-out2.pdf", num_pages, first_image, true))
- return (1);
+ goto fail;
+
+ pdfioFileClose(inpdf);
// Create new encrypted PDF files...
fputs("pdfioFileCreate(\"testpdfio-rc4.pdf\", ...): ", stdout);
@@ -1108,6 +1110,12 @@ do_unit_tests(void)
return (1);
return (0);
+
+ fail:
+
+ pdfioFileClose(inpdf);
+
+ return (1);
}