summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-12-23 14:06:25 +0100
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-12-23 14:06:25 +0100
commit79a9578a33ecd3093970bd18df677edc9214fafb (patch)
tree8ae5c6780a1fcd2124e71f27ad9b4256acd24268 /examples
parent1bb1ce141783168d44a38cd1bb6b822eb13114fc (diff)
downloadlzo-79a9578a33ecd3093970bd18df677edc9214fafb.tar.gz
lzo-79a9578a33ecd3093970bd18df677edc9214fafb.tar.bz2
lzo-79a9578a33ecd3093970bd18df677edc9214fafb.zip
Imported Upstream version 2.08upstream/2.08sandbox/kevinthierry/upstream
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am21
-rw-r--r--examples/Makefile.in491
-rw-r--r--examples/dict.c124
-rw-r--r--examples/lzopack.c124
-rw-r--r--examples/overlap.c155
-rw-r--r--examples/portab.h99
-rw-r--r--examples/portab_a.h101
-rw-r--r--examples/precomp.c77
-rw-r--r--examples/precomp2.c83
-rw-r--r--examples/simple.c48
10 files changed, 314 insertions, 1009 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
deleted file mode 100644
index 2c5b527..0000000
--- a/examples/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-## Process this file with automake to create Makefile.in
-#
-# Copyright (C) 1996-2008 Markus F.X.J. Oberhumer
-#
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)
-
-noinst_PROGRAMS = dict lzopack overlap precomp precomp2 simple
-
-dict_SOURCES = dict.c
-lzopack_SOURCES = lzopack.c
-overlap_SOURCES = overlap.c
-precomp_SOURCES = precomp.c
-precomp2_SOURCES = precomp2.c
-simple_SOURCES = simple.c
-
-LDADD = ../src/liblzo2.la
-DEPENDENCIES = ../src/liblzo2.la
-
-EXTRA_DIST = portab.h portab_a.h
-
diff --git a/examples/Makefile.in b/examples/Makefile.in
deleted file mode 100644
index 4199078..0000000
--- a/examples/Makefile.in
+++ /dev/null
@@ -1,491 +0,0 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-#
-# Copyright (C) 1996-2008 Markus F.X.J. Oberhumer
-#
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = ..
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-target_triplet = @target@
-noinst_PROGRAMS = dict$(EXEEXT) lzopack$(EXEEXT) overlap$(EXEEXT) \
- precomp$(EXEEXT) precomp2$(EXEEXT) simple$(EXEEXT)
-subdir = examples
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/autoconf/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-PROGRAMS = $(noinst_PROGRAMS)
-am_dict_OBJECTS = dict.$(OBJEXT)
-dict_OBJECTS = $(am_dict_OBJECTS)
-dict_LDADD = $(LDADD)
-dict_DEPENDENCIES = ../src/liblzo2.la
-am_lzopack_OBJECTS = lzopack.$(OBJEXT)
-lzopack_OBJECTS = $(am_lzopack_OBJECTS)
-lzopack_LDADD = $(LDADD)
-lzopack_DEPENDENCIES = ../src/liblzo2.la
-am_overlap_OBJECTS = overlap.$(OBJEXT)
-overlap_OBJECTS = $(am_overlap_OBJECTS)
-overlap_LDADD = $(LDADD)
-overlap_DEPENDENCIES = ../src/liblzo2.la
-am_precomp_OBJECTS = precomp.$(OBJEXT)
-precomp_OBJECTS = $(am_precomp_OBJECTS)
-precomp_LDADD = $(LDADD)
-precomp_DEPENDENCIES = ../src/liblzo2.la
-am_precomp2_OBJECTS = precomp2.$(OBJEXT)
-precomp2_OBJECTS = $(am_precomp2_OBJECTS)
-precomp2_LDADD = $(LDADD)
-precomp2_DEPENDENCIES = ../src/liblzo2.la
-am_simple_OBJECTS = simple.$(OBJEXT)
-simple_OBJECTS = $(am_simple_OBJECTS)
-simple_LDADD = $(LDADD)
-simple_DEPENDENCIES = ../src/liblzo2.la
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp
-am__depfiles_maybe = depfiles
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(dict_SOURCES) $(lzopack_SOURCES) $(overlap_SOURCES) \
- $(precomp_SOURCES) $(precomp2_SOURCES) $(simple_SOURCES)
-DIST_SOURCES = $(dict_SOURCES) $(lzopack_SOURCES) $(overlap_SOURCES) \
- $(precomp_SOURCES) $(precomp2_SOURCES) $(simple_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
-AMTAR = @AMTAR@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-LZO_ASM_VPATH = @LZO_ASM_VPATH@
-LZO_CFLAGS = @LZO_CFLAGS@
-LZO_CPPFLAGS = @LZO_CPPFLAGS@
-LZO_EXTRA_CFLAGS = @LZO_EXTRA_CFLAGS@
-LZO_EXTRA_CPPFLAGS = @LZO_EXTRA_CPPFLAGS@
-LZO_USE_ASM_FALSE = @LZO_USE_ASM_FALSE@
-LZO_USE_ASM_TRUE = @LZO_USE_ASM_TRUE@
-MAINT = @MAINT@
-MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
-MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
-MAKEINFO = @MAKEINFO@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-RANLIB = @RANLIB@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
-am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-configure_CFLAGS = @configure_CFLAGS@
-configure_CPPFLAGS = @configure_CPPFLAGS@
-datadir = @datadir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target = @target@
-target_alias = @target_alias@
-target_cpu = @target_cpu@
-target_os = @target_os@
-target_vendor = @target_vendor@
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)
-dict_SOURCES = dict.c
-lzopack_SOURCES = lzopack.c
-overlap_SOURCES = overlap.c
-precomp_SOURCES = precomp.c
-precomp2_SOURCES = precomp2.c
-simple_SOURCES = simple.c
-LDADD = ../src/liblzo2.la
-DEPENDENCIES = ../src/liblzo2.la
-EXTRA_DIST = portab.h portab_a.h
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
- cd $(top_srcdir) && \
- $(AUTOMAKE) --gnu examples/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-clean-noinstPROGRAMS:
- @list='$(noinst_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
-dict$(EXEEXT): $(dict_OBJECTS) $(dict_DEPENDENCIES)
- @rm -f dict$(EXEEXT)
- $(LINK) $(dict_LDFLAGS) $(dict_OBJECTS) $(dict_LDADD) $(LIBS)
-lzopack$(EXEEXT): $(lzopack_OBJECTS) $(lzopack_DEPENDENCIES)
- @rm -f lzopack$(EXEEXT)
- $(LINK) $(lzopack_LDFLAGS) $(lzopack_OBJECTS) $(lzopack_LDADD) $(LIBS)
-overlap$(EXEEXT): $(overlap_OBJECTS) $(overlap_DEPENDENCIES)
- @rm -f overlap$(EXEEXT)
- $(LINK) $(overlap_LDFLAGS) $(overlap_OBJECTS) $(overlap_LDADD) $(LIBS)
-precomp$(EXEEXT): $(precomp_OBJECTS) $(precomp_DEPENDENCIES)
- @rm -f precomp$(EXEEXT)
- $(LINK) $(precomp_LDFLAGS) $(precomp_OBJECTS) $(precomp_LDADD) $(LIBS)
-precomp2$(EXEEXT): $(precomp2_OBJECTS) $(precomp2_DEPENDENCIES)
- @rm -f precomp2$(EXEEXT)
- $(LINK) $(precomp2_LDFLAGS) $(precomp2_OBJECTS) $(precomp2_LDADD) $(LIBS)
-simple$(EXEEXT): $(simple_OBJECTS) $(simple_DEPENDENCIES)
- @rm -f simple$(EXEEXT)
- $(LINK) $(simple_LDFLAGS) $(simple_OBJECTS) $(simple_LDADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dict.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzopack.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/overlap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/precomp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/precomp2.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple.Po@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-distclean-libtool:
- -rm -f libtool
-uninstall-info-am:
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$tags $$unique; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(CTAGS_ARGS)$$tags$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$tags $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && cd $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
- list='$(DISTFILES)'; for file in $$list; do \
- case $$file in \
- $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
- $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
- esac; \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test "$$dir" != "$$file" && test "$$dir" != "."; then \
- dir="/$$dir"; \
- $(mkdir_p) "$(distdir)$$dir"; \
- else \
- dir=''; \
- fi; \
- if test -d $$d/$$file; then \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
- fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
- else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: check-am
-all-am: Makefile $(PROGRAMS)
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
- mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-libtool distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-exec-am:
-
-install-info: install-info-am
-
-install-man:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-info-am
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-noinstPROGRAMS ctags distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-exec \
- install-exec-am install-info install-info-am install-man \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags uninstall uninstall-am \
- uninstall-info-am
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/examples/dict.c b/examples/dict.c
index eec7675..3ccc9a5 100644
--- a/examples/dict.c
+++ b/examples/dict.c
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -48,18 +36,18 @@
#include "lzo/lzo1x.h"
/* portability layer */
+static const char *progname = NULL;
#define WANT_LZO_MALLOC 1
#define WANT_LZO_FREAD 1
#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
#include "examples/portab.h"
-static const char *progname = NULL;
-
#define DICT_LEN 0xbfff
static lzo_bytep dict;
static lzo_uint dict_len = 0;
-static lzo_uint32 dict_adler32;
+static lzo_uint32_t dict_adler32;
/*************************************************************************
@@ -70,11 +58,11 @@ static lzo_uint total_n = 0;
static lzo_uint total_c_len = 0;
static lzo_uint total_d_len = 0;
-static void print_file ( const char *name, lzo_uint d_len, lzo_uint c_len )
+static void print_info(const char *name, lzo_uint d_len, lzo_uint c_len)
{
double perc;
- perc = (d_len > 0) ? c_len * 100.0 / d_len : 0;
+ perc = (d_len > 0) ? c_len * 100.0 / d_len : 0.0;
printf(" | %-30s %9ld -> %9ld %7.2f%% |\n",
name, (long) d_len, (long) c_len, perc);
@@ -88,59 +76,65 @@ static void print_file ( const char *name, lzo_uint d_len, lzo_uint c_len )
//
**************************************************************************/
-int do_file ( const char *in_name, int level )
+static int do_file(const char *in_name, int compression_level)
{
int r;
lzo_bytep in;
lzo_bytep out;
lzo_bytep newb;
- lzo_bytep wrkmem;
+ lzo_voidp wrkmem;
lzo_uint in_len;
lzo_uint out_len;
lzo_uint new_len;
long l;
- FILE *f;
+ FILE *fp;
/*
* Step 1: open the input file
*/
- f = fopen(in_name,"rb");
- if (f == 0)
+ fp = fopen(in_name,"rb");
+ if (fp == NULL)
{
- printf("%s: cannot open file %s\n", progname, in_name);
+ printf("%s: %s: cannot open file\n", progname, in_name);
return 0; /* no error */
}
- fseek(f,0,SEEK_END);
- l = ftell(f);
- fseek(f,0,SEEK_SET);
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
if (l <= 0)
{
printf("%s: %s: empty file -- skipping\n", progname, in_name);
- fclose(f);
- return 0;
+ fclose(fp); fp = NULL;
+ return 0; /* no error */
}
in_len = (lzo_uint) l;
+ if ((long) in_len != l || l > 256L * 1024L * 1024L)
+ {
+ printf("%s: %s: file is too big -- skipping\n", progname, in_name);
+ fclose(fp); fp = NULL;
+ return 0; /* no error */
+ }
/*
* Step 2: allocate compression buffers and read the file
*/
- in = (lzo_bytep) lzo_malloc(in_len);
- out = (lzo_bytep) lzo_malloc(in_len + in_len / 16 + 64 + 3);
- newb = (lzo_bytep) lzo_malloc(in_len);
- wrkmem = (lzo_bytep) lzo_malloc(LZO1X_999_MEM_COMPRESS);
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(in_len + in_len / 16 + 64 + 3);
+ newb = (lzo_bytep) xmalloc(in_len);
+ wrkmem = (lzo_voidp) xmalloc(LZO1X_999_MEM_COMPRESS);
if (in == NULL || out == NULL || newb == NULL || wrkmem == NULL)
{
printf("%s: out of memory\n", progname);
exit(1);
}
- in_len = (lzo_uint) lzo_fread(f,in,in_len);
- fclose(f);
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
+ fclose(fp); fp = NULL;
/*
- * Step 3: compress from `in' to `out' with LZO1X-999
+ * Step 3: compress from 'in' to 'out' with LZO1X-999
*/
r = lzo1x_999_compress_level(in,in_len,out,&out_len,wrkmem,
- dict, dict_len, 0, level);
+ dict, dict_len, 0, compression_level);
if (r != LZO_E_OK)
{
/* this should NEVER happen */
@@ -148,13 +142,13 @@ int do_file ( const char *in_name, int level )
return 1;
}
- print_file(in_name,in_len,out_len);
+ print_info(in_name, in_len, out_len);
/*
- * Step 4: decompress again, now going from `out' to `newb'
+ * Step 4: decompress again, now going from 'out' to 'newb'
*/
new_len = in_len;
- r = lzo1x_decompress_dict_safe(out,out_len,newb,&new_len,NULL,dict,dict_len);
+ r = lzo1x_decompress_dict_safe(out, out_len, newb, &new_len, NULL, dict, dict_len);
if (r != LZO_E_OK)
{
/* this should NEVER happen */
@@ -165,7 +159,7 @@ int do_file ( const char *in_name, int level )
/*
* Step 5: verify decompression
*/
- if (new_len != in_len || lzo_memcmp(in,newb,in_len) != 0)
+ if (new_len != in_len || lzo_memcmp(in, newb, in_len) != 0)
{
/* this should NEVER happen */
printf("internal error - decompression data error\n");
@@ -188,29 +182,29 @@ int do_file ( const char *in_name, int level )
int __lzo_cdecl_main main(int argc, char *argv[])
{
int i = 1;
- int r;
+ int r = 0;
const char *dict_name;
- FILE *f;
+ FILE *fp;
time_t t_total;
- int level = 7;
+ int compression_level = 7;
lzo_wildargv(&argc, &argv);
printf("\nLZO real-time data compression library (v%s, %s).\n",
lzo_version_string(), lzo_version_date());
- printf("Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+ printf("Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
progname = argv[0];
if (i < argc && argv[i][0] == '-' && isdigit(argv[i][1]))
- level = atoi(&argv[i++][1]);
+ compression_level = atoi(&argv[i++][1]);
- if (i + 1 >= argc || level < 1 || level > 9)
+ if (i + 1 >= argc || compression_level < 1 || compression_level > 9)
{
printf("usage: %s [-level] [ dictionary-file | -n ] file...\n", progname);
exit(1);
}
- printf("Compression level is LZO1X-999/%d\n", level);
+ printf("Compression level is LZO1X-999/%d\n", compression_level);
/*
* Step 1: initialize the LZO library
@@ -218,14 +212,14 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (lzo_init() != LZO_E_OK)
{
printf("internal error - lzo_init() failed !!!\n");
- printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n");
+ printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");
exit(1);
}
/*
* Step 2: prepare the dictionary
*/
- dict = (lzo_bytep) lzo_malloc(DICT_LEN);
+ dict = (lzo_bytep) xmalloc(DICT_LEN);
if (dict == NULL)
{
printf("%s: out of memory\n", progname);
@@ -239,40 +233,42 @@ int __lzo_cdecl_main main(int argc, char *argv[])
}
else
{
- f = fopen(dict_name,"rb");
- if (!f)
+ fp = fopen(dict_name,"rb");
+ if (fp == NULL)
{
printf("%s: cannot open dictionary file %s\n", progname, dict_name);
exit(1);
}
- dict_len = (lzo_uint) lzo_fread(f,dict,DICT_LEN);
- fclose(f);
+ dict_len = (lzo_uint) lzo_fread(fp, dict, DICT_LEN);
+ fclose(fp); fp = NULL;
}
- dict_adler32 = lzo_adler32(0,NULL,0);
- dict_adler32 = lzo_adler32(dict_adler32,dict,dict_len);
+ dict_adler32 = lzo_adler32(0, NULL, 0);
+ dict_adler32 = lzo_adler32(dict_adler32, dict, dict_len);
printf("Using dictionary '%s', %ld bytes, ID 0x%08lx.\n",
- dict_name, (long) dict_len, (long) dict_adler32);
+ dict_name, (long) dict_len, (unsigned long) dict_adler32);
/*
* Step 3: process files
*/
t_total = time(NULL);
- for (r = 0; r == 0 && i < argc; i++)
- r = do_file(argv[i], level);
+ for ( ; i < argc; i++) {
+ if (do_file(argv[i], compression_level) != 0) {
+ r = 1;
+ break;
+ }
+ }
t_total = time(NULL) - t_total;
lzo_free(dict);
if (total_n > 1)
- print_file("***TOTALS***",total_d_len,total_c_len);
+ print_info("***TOTALS***", total_d_len, total_c_len);
printf("Dictionary compression test %s, execution time %lu seconds.\n",
- r == 0 ? "passed" : "FAILED", (unsigned long) t_total);
+ r == 0 ? "passed" : "FAILED", (unsigned long) t_total);
return r;
}
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */
diff --git a/examples/lzopack.c b/examples/lzopack.c
index 6a3d848..1f7d0e2 100644
--- a/examples/lzopack.c
+++ b/examples/lzopack.c
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -52,14 +40,14 @@
#include "lzo/lzo1x.h"
/* portability layer */
+static const char *progname = NULL;
#define WANT_LZO_MALLOC 1
#define WANT_LZO_FREAD 1
#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
#include "examples/portab.h"
-static const char *progname = NULL;
-
static unsigned long total_in = 0;
static unsigned long total_out = 0;
static lzo_bool opt_debug = 0;
@@ -73,30 +61,30 @@ static const unsigned char magic[7] =
// file IO
**************************************************************************/
-lzo_uint xread(FILE *fp, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof)
+static lzo_uint xread(FILE *fp, lzo_voidp buf, lzo_uint len, lzo_bool allow_eof)
{
lzo_uint l;
l = (lzo_uint) lzo_fread(fp, buf, len);
if (l > len)
{
- fprintf(stderr, "\nsomething's wrong with your C library !!!\n");
+ fprintf(stderr, "\n%s: internal error - something is wrong with your C library !!!\n", progname);
exit(1);
}
if (l != len && !allow_eof)
{
- fprintf(stderr, "\nread error - premature end of file\n");
+ fprintf(stderr, "\n%s: read error - premature end of file\n", progname);
exit(1);
}
total_in += (unsigned long) l;
return l;
}
-lzo_uint xwrite(FILE *fp, const lzo_voidp buf, lzo_uint len)
+static lzo_uint xwrite(FILE *fp, const lzo_voidp buf, lzo_uint len)
{
if (fp != NULL && lzo_fwrite(fp, buf, len) != len)
{
- fprintf(stderr, "\nwrite error (disk full ?)\n");
+ fprintf(stderr, "\n%s: write error (disk full ?)\n", progname);
exit(1);
}
total_out += (unsigned long) len;
@@ -104,14 +92,14 @@ lzo_uint xwrite(FILE *fp, const lzo_voidp buf, lzo_uint len)
}
-int xgetc(FILE *fp)
+static int xgetc(FILE *fp)
{
unsigned char c;
xread(fp, (lzo_voidp) &c, 1, 0);
return c;
}
-void xputc(FILE *fp, int c)
+static void xputc(FILE *fp, int c)
{
unsigned char cc = (unsigned char) (c & 0xff);
xwrite(fp, (const lzo_voidp) &cc, 1);
@@ -119,20 +107,20 @@ void xputc(FILE *fp, int c)
/* read and write portable 32-bit integers */
-lzo_uint32 xread32(FILE *fp)
+static lzo_uint32_t xread32(FILE *fp)
{
unsigned char b[4];
- lzo_uint32 v;
+ lzo_uint32_t v;
xread(fp, b, 4, 0);
- v = (lzo_uint32) b[3] << 0;
- v |= (lzo_uint32) b[2] << 8;
- v |= (lzo_uint32) b[1] << 16;
- v |= (lzo_uint32) b[0] << 24;
+ v = (lzo_uint32_t) b[3] << 0;
+ v |= (lzo_uint32_t) b[2] << 8;
+ v |= (lzo_uint32_t) b[1] << 16;
+ v |= (lzo_uint32_t) b[0] << 24;
return v;
}
-void xwrite32(FILE *fp, lzo_xint v)
+static void xwrite32(FILE *fp, lzo_uint v)
{
unsigned char b[4];
@@ -156,18 +144,18 @@ void xwrite32(FILE *fp, lzo_xint v)
// compression.
**************************************************************************/
-int do_compress(FILE *fi, FILE *fo, int level, lzo_uint block_size)
+static int do_compress(FILE *fi, FILE *fo, int compression_level, lzo_uint block_size)
{
int r = 0;
lzo_bytep in = NULL;
lzo_bytep out = NULL;
- lzo_bytep wrkmem = NULL;
+ lzo_voidp wrkmem = NULL;
lzo_uint in_len;
lzo_uint out_len;
- lzo_uint32 wrk_len = 0;
- lzo_uint32 flags = 1; /* do compute a checksum */
+ lzo_uint wrkmem_size;
+ lzo_uint32_t flags = 1; /* do compute a checksum */
int method = 1; /* compression method: LZO1X */
- lzo_uint32 checksum;
+ lzo_uint32_t checksum;
total_in = total_out = 0;
@@ -176,21 +164,21 @@ int do_compress(FILE *fi, FILE *fo, int level, lzo_uint block_size)
*/
xwrite(fo, magic, sizeof(magic));
xwrite32(fo, flags);
- xputc(fo, method); /* compression method */
- xputc(fo, level); /* compression level */
+ xputc(fo, method); /* compression method */
+ xputc(fo, compression_level); /* compression level */
xwrite32(fo, block_size);
checksum = lzo_adler32(0, NULL, 0);
/*
* Step 2: allocate compression buffers and work-memory
*/
- in = (lzo_bytep) lzo_malloc(block_size);
- out = (lzo_bytep) lzo_malloc(block_size + block_size / 16 + 64 + 3);
- if (level == 9)
- wrk_len = LZO1X_999_MEM_COMPRESS;
+ in = (lzo_bytep) xmalloc(block_size);
+ out = (lzo_bytep) xmalloc(block_size + block_size / 16 + 64 + 3);
+ if (compression_level == 9)
+ wrkmem_size = LZO1X_999_MEM_COMPRESS;
else
- wrk_len = LZO1X_1_MEM_COMPRESS;
- wrkmem = (lzo_bytep) lzo_malloc(wrk_len);
+ wrkmem_size = LZO1X_1_MEM_COMPRESS;
+ wrkmem = (lzo_voidp) xmalloc(wrkmem_size);
if (in == NULL || out == NULL || wrkmem == NULL)
{
printf("%s: out of memory\n", progname);
@@ -205,7 +193,7 @@ int do_compress(FILE *fi, FILE *fo, int level, lzo_uint block_size)
{
/* read block */
in_len = xread(fi, in, block_size, 1);
- if (in_len <= 0)
+ if (in_len == 0)
break;
/* update checksum */
@@ -214,10 +202,10 @@ int do_compress(FILE *fi, FILE *fo, int level, lzo_uint block_size)
/* clear wrkmem (not needed, only for debug/benchmark purposes) */
if (opt_debug)
- lzo_memset(wrkmem, 0xff, wrk_len);
+ lzo_memset(wrkmem, 0xff, wrkmem_size);
/* compress block */
- if (level == 9)
+ if (compression_level == 9)
r = lzo1x_999_compress(in, in_len, out, &out_len, wrkmem);
else
r = lzo1x_1_compress(in, in_len, out, &out_len, wrkmem);
@@ -269,24 +257,24 @@ err:
// memory - see overlap.c.
**************************************************************************/
-int do_decompress(FILE *fi, FILE *fo)
+static int do_decompress(FILE *fi, FILE *fo)
{
int r = 0;
lzo_bytep buf = NULL;
lzo_uint buf_len;
unsigned char m [ sizeof(magic) ];
- lzo_uint32 flags;
+ lzo_uint32_t flags;
int method;
- int level;
+ int compression_level;
lzo_uint block_size;
- lzo_uint32 checksum;
+ lzo_uint32_t checksum;
total_in = total_out = 0;
/*
* Step 1: check magic header, read flags & block size, init checksum
*/
- if (xread(fi, m, sizeof(magic),1) != sizeof(magic) ||
+ if (xread(fi, m, sizeof(magic), 1) != sizeof(magic) ||
memcmp(m, magic, sizeof(magic)) != 0)
{
printf("%s: header error - this file is not compressed by lzopack\n", progname);
@@ -295,29 +283,29 @@ int do_decompress(FILE *fi, FILE *fo)
}
flags = xread32(fi);
method = xgetc(fi);
- level = xgetc(fi);
+ compression_level = xgetc(fi);
if (method != 1)
{
printf("%s: header error - invalid method %d (level %d)\n",
- progname, method, level);
+ progname, method, compression_level);
r = 2;
goto err;
}
block_size = xread32(fi);
- if (block_size < 1024 || block_size > 8*1024*1024L)
+ if (block_size < 1024 || block_size > 8L * 1024L * 1024L)
{
printf("%s: header error - invalid block size %ld\n",
progname, (long) block_size);
r = 3;
goto err;
}
- checksum = lzo_adler32(0,NULL,0);
+ checksum = lzo_adler32(0, NULL, 0);
/*
* Step 2: allocate buffer for in-place decompression
*/
buf_len = block_size + block_size / 16 + 64 + 3;
- buf = (lzo_bytep) lzo_malloc(buf_len);
+ buf = (lzo_bytep) xmalloc(buf_len);
if (buf == NULL)
{
printf("%s: out of memory\n", progname);
@@ -393,7 +381,7 @@ int do_decompress(FILE *fi, FILE *fo)
/* read and verify checksum */
if (flags & 1)
{
- lzo_uint32 c = xread32(fi);
+ lzo_uint32_t c = xread32(fi);
if (c != checksum)
{
printf("%s: checksum error - data corrupted\n", progname);
@@ -506,9 +494,9 @@ int __lzo_cdecl_main main(int argc, char *argv[])
FILE *fo = NULL;
const char *in_name = NULL;
const char *out_name = NULL;
- lzo_bool opt_decompress = 0;
- lzo_bool opt_test = 0;
- int opt_level = 1;
+ unsigned opt_decompress = 0;
+ unsigned opt_test = 0;
+ int opt_compression_level = 1;
lzo_uint opt_block_size;
const char *s;
@@ -521,7 +509,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
printf("\nLZO real-time data compression library (v%s, %s).\n",
lzo_version_string(), lzo_version_date());
- printf("Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+ printf("Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
#if 0
printf(
@@ -539,7 +527,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (lzo_init() != LZO_E_OK)
{
printf("internal error - lzo_init() failed !!!\n");
- printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n");
+ printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");
exit(1);
}
@@ -549,9 +537,9 @@ int __lzo_cdecl_main main(int argc, char *argv[])
*/
opt_block_size = 256 * 1024L;
-#if defined(ACC_MM_AHSHIFT)
+#if defined(LZO_MM_AHSHIFT)
/* reduce memory requirements for ancient 16-bit DOS 640kB real-mode */
- if (ACC_MM_AHSHIFT != 3)
+ if (LZO_MM_AHSHIFT != 3)
opt_block_size = 16 * 1024L;
#endif
@@ -567,7 +555,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
else if (strcmp(argv[i],"-t") == 0)
opt_test = 1;
else if (strcmp(argv[i],"-9") == 0)
- opt_level = 9;
+ opt_compression_level = 9;
else if (argv[i][1] == 'b' && argv[i][2])
{
long b = atol(&argv[i][2]);
@@ -575,7 +563,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
opt_block_size = (lzo_uint) b;
else
{
- printf("%s: invalid block_size in option `%s'.\n", progname, argv[i]);
+ printf("%s: invalid block_size in option '%s'.\n", progname, argv[i]);
usage();
}
}
@@ -625,7 +613,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
out_name = argv[i++];
fi = xopen_fi(in_name);
fo = xopen_fo(out_name);
- r = do_compress(fi, fo, opt_level, opt_block_size);
+ r = do_compress(fi, fo, opt_compression_level, opt_block_size);
if (r == 0)
printf("%s: compressed %lu into %lu bytes\n",
progname, total_in, total_out);
@@ -636,7 +624,5 @@ int __lzo_cdecl_main main(int argc, char *argv[])
return r;
}
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */
diff --git a/examples/overlap.c b/examples/overlap.c
index 7eeb52f..114fe3b 100644
--- a/examples/overlap.c
+++ b/examples/overlap.c
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -49,15 +37,17 @@
#include "lzo/lzo1x.h"
/* portability layer */
+static const char *progname = NULL;
#define WANT_LZO_MALLOC 1
#define WANT_LZO_FREAD 1
#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
#include "examples/portab.h"
/* Overhead (in bytes) for the in-place decompression buffer.
* Most files need only 16 !
- * (try `overlap -16 file' or even `overlap -8 file')
+ * (try 'overlap -16 file' or even 'overlap -8 file')
*
* Worst case (for files that are compressible by only a few bytes)
* is 'in_len / 16 + 64 + 3'. See step 5a) below.
@@ -66,51 +56,23 @@
* will be needed. See step 4a) below.
*/
-static lzo_uint opt_overhead = 0; /* assume worst case */
-
-
-#if 0 && defined(LZO_USE_ASM)
- /* just for testing */
-# include <lzo_asm.h>
-# define lzo1x_decompress lzo1x_decompress_asm_fast
-#endif
-
-
-/*************************************************************************
-//
-**************************************************************************/
-
-static const char *progname = NULL;
+static long opt_overhead = 0; /* assume worst case */
static unsigned long total_files = 0;
static unsigned long total_in = 0;
-static lzo_bytep xmalloc(lzo_uint len)
-{
- lzo_bytep p;
-
- p = (lzo_bytep) lzo_malloc(len > 0 ? len : 1);
- if (p == NULL)
- {
- printf("%s: out of memory\n", progname);
- exit(1);
- }
- return p;
-}
-
-
/*************************************************************************
//
**************************************************************************/
-int do_file ( const char *in_name )
+static int do_file(const char *in_name)
{
int r;
- FILE *f = NULL;
+ FILE *fp = NULL;
long l;
- lzo_bytep wrkmem = NULL;
+ lzo_voidp wrkmem = NULL;
lzo_bytep in = NULL;
lzo_uint in_len; /* uncompressed length */
@@ -127,59 +89,64 @@ int do_file ( const char *in_name )
/*
* Step 1: open the input file
*/
- f = fopen(in_name,"rb");
- if (f == NULL)
+ fp = fopen(in_name, "rb");
+ if (fp == NULL)
{
printf("%s: %s: cannot open file\n", progname, in_name);
goto next_file;
}
- fseek(f,0,SEEK_END);
- l = ftell(f);
- fseek(f,0,SEEK_SET);
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
if (l <= 0)
{
printf("%s: %s: empty file -- skipping\n", progname, in_name);
goto next_file;
}
in_len = (lzo_uint) l;
+ if ((long) in_len != l || l > 256L * 1024L * 1024L)
+ {
+ printf("%s: %s: file is too big -- skipping\n", progname, in_name);
+ goto next_file;
+ }
/*
* Step 2: allocate compression buffers and read the file
*/
- in = xmalloc(in_len);
- out = xmalloc(in_len + in_len / 16 + 64 + 3);
- wrkmem = xmalloc(LZO1X_1_MEM_COMPRESS);
- in_len = (lzo_uint) lzo_fread(f,in,in_len);
- fclose(f); f = NULL;
- printf("%s: %s: read %ld bytes\n", progname, in_name, (long) in_len);
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(in_len + in_len / 16 + 64 + 3);
+ wrkmem = (lzo_voidp) xmalloc(LZO1X_1_MEM_COMPRESS);
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
+ fclose(fp); fp = NULL;
+ printf("%s: %s: read %lu bytes\n", progname, in_name, (unsigned long) in_len);
total_files++;
total_in += (unsigned long) in_len;
/*
- * Step 3: compress from `in' to `out' with LZO1X-1
+ * Step 3: compress from 'in' to 'out' with LZO1X-1
*/
- r = lzo1x_1_compress(in,in_len,out,&out_len,wrkmem);
+ r = lzo1x_1_compress(in, in_len, out, &out_len, wrkmem);
if (r != LZO_E_OK || out_len > in_len + in_len / 16 + 64 + 3)
{
/* this should NEVER happen */
printf("internal error - compression failed: %d\n", r);
exit(1);
}
- printf("%-26s %8lu -> %8lu\n", "LZO1X-1:", (long) in_len, (long) out_len);
+ printf("%-25s %8lu -> %8lu\n", "LZO1X-1:", (unsigned long) in_len, (unsigned long) out_len);
/***** Step 4: overlapping compression *****/
/*
- * Step 4a: allocate the `overlap' buffer for overlapping compression
+ * Step 4a: allocate the 'overlap' buffer for overlapping compression
*/
overhead = in_len > 0xbfff ? 0xbfff : in_len;
overhead += in_len / 16 + 64 + 3;
- overlap = xmalloc(in_len + overhead);
+ overlap = (lzo_bytep) xmalloc(in_len + overhead);
/*
- * Step 4b: prepare data in `overlap' buffer.
+ * Step 4b: prepare data in 'overlap' buffer.
* copy uncompressed data at the top of the overlap buffer
*/
/*** offset = in_len + overhead - in_len; ***/
@@ -187,84 +154,84 @@ int do_file ( const char *in_name )
lzo_memcpy(overlap + offset, in, in_len);
/*
- * Step 4c: do an in-place compression within the `overlap' buffer
+ * Step 4c: do an in-place compression within the 'overlap' buffer
*/
- r = lzo1x_1_compress(overlap+offset,in_len,overlap,&new_len,wrkmem);
+ r = lzo1x_1_compress(overlap + offset, in_len, overlap, &new_len, wrkmem);
if (r != LZO_E_OK)
{
/* this should NEVER happen */
- printf("overlapping compression failed: %d\n", r);
+ printf("in-place compression failed: %d\n", r);
exit(1);
}
/*
* Step 4d: verify overlapping compression
*/
- if (new_len != out_len || lzo_memcmp(out,overlap,out_len) != 0)
+ if (new_len != out_len || lzo_memcmp(out, overlap, out_len) != 0)
{
/* As compression is non-deterministic there can be a difference
* in the representation of the compressed data (but this usually
* happens very seldom). So we have to verify the overlapping
* compression by doing a temporary decompression.
*/
- lzo_uint l = in_len;
- lzo_bytep tmp = xmalloc(l);
- r = lzo1x_decompress_safe(overlap,new_len,tmp,&l,NULL);
- if (r != LZO_E_OK || l != in_len || lzo_memcmp(in,tmp,l) != 0)
+ lzo_uint ll = in_len;
+ lzo_bytep tmp = (lzo_bytep) xmalloc(ll);
+ r = lzo1x_decompress_safe(overlap, new_len, tmp, &ll, NULL);
+ if (r != LZO_E_OK || ll != in_len || lzo_memcmp(in, tmp, ll) != 0)
{
/* this should NEVER happen */
- printf("overlapping compression data error\n");
+ printf("in-place compression data error\n");
exit(1);
}
lzo_free(tmp);
}
- printf("overlapping compression: %8lu -> %8lu overhead: %7ld\n",
- (long) in_len, (long) new_len, (long) overhead);
+ printf(" in-place compression: %8lu -> %8lu overhead: %7lu\n",
+ (unsigned long) in_len, (unsigned long) new_len, (unsigned long) overhead);
lzo_free(overlap); overlap = NULL;
-/***** Step 5: overlapping decompression *****/
+/***** Step 5: in-place decompression *****/
/*
- * Step 5a: allocate the `overlap' buffer for in-place decompression
+ * Step 5a: allocate the 'overlap' buffer for in-place decompression
*/
if (opt_overhead == 0 || out_len >= in_len)
overhead = in_len / 16 + 64 + 3;
else
- overhead = opt_overhead;
- overlap = xmalloc(in_len + overhead);
+ overhead = (lzo_uint) opt_overhead;
+ overlap = (lzo_bytep) xmalloc(in_len + overhead);
/*
- * Step 5b: prepare data in `overlap' buffer.
+ * Step 5b: prepare data in 'overlap' buffer.
* copy compressed data at the top of the overlap buffer
*/
offset = in_len + overhead - out_len;
lzo_memcpy(overlap + offset, out, out_len);
/*
- * Step 5c: do an in-place decompression within the `overlap' buffer
+ * Step 5c: do an in-place decompression within the 'overlap' buffer
*/
new_len = in_len;
- r = lzo1x_decompress(overlap+offset,out_len,overlap,&new_len,NULL);
+ r = lzo1x_decompress_safe(overlap + offset, out_len, overlap, &new_len, NULL);
if (r != LZO_E_OK)
{
/* this may happen if overhead is too small */
- printf("overlapping decompression failed: %d - increase `opt_overhead'\n", r);
+ printf("in-place decompression failed: %d - increase 'opt_overhead'\n", r);
exit(1);
}
/*
* Step 5d: verify decompression
*/
- if (new_len != in_len || lzo_memcmp(in,overlap,in_len) != 0)
+ if (new_len != in_len || lzo_memcmp(in, overlap, in_len) != 0)
{
/* this may happen if overhead is too small */
- printf("overlapping decompression data error - increase `opt_overhead'\n");
+ printf("in-place decompression data error - increase 'opt_overhead'\n");
exit(1);
}
- printf("overlapping decompression: %8lu -> %8lu overhead: %7ld\n",
- (long) out_len, (long) new_len, (long) overhead);
+ printf(" in-place decompression: %8lu -> %8lu overhead: %7lu\n",
+ (unsigned long) out_len, (unsigned long) new_len, (unsigned long) overhead);
lzo_free(overlap); overlap = NULL;
@@ -273,7 +240,7 @@ next_file:
lzo_free(wrkmem);
lzo_free(out);
lzo_free(in);
- if (f) fclose(f);
+ if (fp) fclose(fp);
return 0;
}
@@ -292,15 +259,15 @@ int __lzo_cdecl_main main(int argc, char *argv[])
printf("\nLZO real-time data compression library (v%s, %s).\n",
lzo_version_string(), lzo_version_date());
- printf("Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+ printf("Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
progname = argv[0];
if (i < argc && argv[i][0] == '-')
- opt_overhead = atoi(&argv[i++][1]);
+ opt_overhead = atol(&argv[i++][1]);
#if 1
- if (opt_overhead != 0 && opt_overhead < 8)
+ if (opt_overhead != 0 && opt_overhead < 4)
{
- printf("%s: invalid overhead value %ld\n", progname, (long)opt_overhead);
+ printf("%s: invalid overhead value %ld\n", progname, opt_overhead);
exit(1);
}
#endif
@@ -316,7 +283,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (lzo_init() != LZO_E_OK)
{
printf("internal error - lzo_init() failed !!!\n");
- printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n");
+ printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");
exit(1);
}
@@ -331,7 +298,5 @@ int __lzo_cdecl_main main(int argc, char *argv[])
return r;
}
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */
diff --git a/examples/portab.h b/examples/portab.h
index 1405b44..d8217ed 100644
--- a/examples/portab.h
+++ b/examples/portab.h
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -41,17 +29,21 @@
#include "lzo/lzoconf.h"
#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1200))
- /* avoid `-W4' warnings in system header files */
+ /* avoid '-W4' warnings in system header files */
# pragma warning(disable: 4201 4214 4514)
#endif
#if (LZO_CC_MSC && (_MSC_VER >= 1300))
- /* avoid `-Wall' warnings in system header files */
+ /* avoid '-Wall' warnings in system header files */
# pragma warning(disable: 4163 4255 4820)
/* avoid warnings about inlining */
# pragma warning(disable: 4710 4711)
#endif
-#if (LZO_CC_MSC && (_MSC_VER >= 1400))
- /* avoid warnings when using "deprecated" POSIX functions */
+/* disable silly warnings about using "deprecated" POSIX functions like "fopen" */
+#if (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1100))
+# pragma warning(disable: 1786)
+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1000))
+# pragma warning(disable: 1478)
+#elif (LZO_CC_MSC && (_MSC_VER >= 1400))
# pragma warning(disable: 4996)
#endif
#if (LZO_CC_PELLESC && (__POCC__ >= 290))
@@ -63,19 +55,13 @@
//
**************************************************************************/
-#if defined(__LZO_MMODEL_HUGE) || !(defined(LZO_LIBC_ISOC90) || defined(LZO_LIBC_ISOC99))
+#if defined(LZO_WANT_ACCLIB_GETOPT) || !(defined(LZO_LIBC_ISOC90) || defined(LZO_LIBC_ISOC99))
#include "examples/portab_a.h"
#else
-/* INFO:
- * The "portab_a.h" version above uses the ACC library to add
- * support for ancient systems (like 16-bit DOS) and to provide
- * some gimmicks like Windows high-resolution timers.
- * Still, on any halfway modern machine you can also use the
- * following pure ANSI-C code instead.
- */
+/* On any halfway modern machine we can use the following pure ANSI-C code. */
#include <stddef.h>
#include <stdlib.h>
@@ -95,13 +81,14 @@
# define lzo_fread(f,b,s) (fread(b,1,s,f))
# define lzo_fwrite(f,b,s) (fwrite(b,1,s,f))
#endif
-#if defined(WANT_LZO_UCLOCK)
-# define lzo_uclock_handle_t int
-# define lzo_uclock_t double
-# define lzo_uclock_open(a) ((void)(a))
-# define lzo_uclock_close(a) ((void)(a))
-# define lzo_uclock_read(a,b) *(b) = (clock() / (double)(CLOCKS_PER_SEC))
-# define lzo_uclock_get_elapsed(a,b,c) (*(c) - *(b))
+#if defined(WANT_LZO_PCLOCK)
+# define lzo_pclock_handle_t int
+# define lzo_pclock_t double
+# define lzo_pclock_open_default(a) ((void)(a))
+# define lzo_pclock_close(a) ((void)(a))
+# define lzo_pclock_read(a,b) *(b) = (clock() / (double)(CLOCKS_PER_SEC))
+# define lzo_pclock_get_elapsed(a,b,c) (*(c) - *(b))
+# define lzo_pclock_flush_cpu_cache(a,b) ((void)(a))
#endif
#if defined(WANT_LZO_WILDARGV)
# define lzo_wildargv(a,b) ((void)0)
@@ -129,34 +116,26 @@
#undef xwrite32
-#if defined(WANT_LZO_UCLOCK)
-
-/* High quality benchmarking.
- *
- * Flush the CPU cache to get more accurate benchmark values.
- * This needs custom kernel patches. As a result - in combination with
- * the perfctr Linux kernel patches - accurate high-quality benchmarking
- * is possible.
- *
- * All other methods (rdtsc, QueryPerformanceCounter, gettimeofday, ...)
- * are completely unreliable for our purposes, and the only other
- * option is to boot into a legacy single-task operating system
- * like plain MSDOS and to directly reprogram the hardware clock.
- * [The djgpp2 port of the gcc compiler has support functions for this.]
- *
- * Also, for embedded systems it's best to benchmark by using a
- * CPU emulator/simulator software that can exactly count all
- * virtual clock ticks.
- */
-
-#if !defined(lzo_uclock_flush_cpu_cache)
-# define lzo_uclock_flush_cpu_cache(h,flags) ((void)(h))
-#endif
-
+#if defined(WANT_XMALLOC)
+static lzo_voidp xmalloc(lzo_uint len)
+{
+ lzo_voidp p;
+ lzo_uint align = (lzo_uint) sizeof(lzo_align_t);
+
+ p = (lzo_voidp) lzo_malloc(len > 0 ? len : 1);
+ if (p == NULL)
+ {
+ printf("%s: out of memory\n", progname);
+ exit(1);
+ }
+ if (len >= align && __lzo_align_gap(p, align) != 0)
+ {
+ printf("%s: C library problem: malloc() returned misaligned pointer!\n", progname);
+ exit(1);
+ }
+ return p;
+}
#endif
-/*
-vi:ts=4:et
-*/
-
+/* vim:set ts=4 sw=4 et: */
diff --git a/examples/portab_a.h b/examples/portab_a.h
index a58ba99..a3fbec9 100644
--- a/examples/portab_a.h
+++ b/examples/portab_a.h
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -39,90 +27,35 @@
/*************************************************************************
-// use the ACC library for the hard work
+//
**************************************************************************/
#if defined(LZO_HAVE_CONFIG_H)
-# define ACC_CONFIG_NO_HEADER 1
+# define LZO_CFG_NO_CONFIG_HEADER 1
#endif
-#define ACC_WANT_ACC_INCD_H 1
-#define ACC_WANT_ACC_INCE_H 1
-#if defined(__LZO_MMODEL_HUGE) || defined(WANT_LZO_UCLOCK) || defined(WANT_LZO_WILDARGV)
-# define ACC_WANT_ACC_INCI_H 1
-# define ACC_WANT_ACC_LIB_H 1
+#define LZO_WANT_ACC_INCD_H 1
+#define LZO_WANT_ACC_INCE_H 1
+#if defined(LZO_WANT_ACCLIB_GETOPT) || defined(WANT_LZO_PCLOCK) || defined(WANT_LZO_WILDARGV)
+# define LZO_WANT_ACC_INCI_H 1
+# define LZO_WANT_ACC_LIB_H 1
#endif
-#include "src/miniacc.h"
-
-#if defined(WANT_LZO_MALLOC)
-# if defined(__LZO_MMODEL_HUGE)
-# define ACC_WANT_ACCLIB_HALLOC 1
-# else
-# define acc_halloc(a) (malloc(a))
-# define acc_hfree(a) (free(a))
-# endif
-#endif
-#if defined(WANT_LZO_FREAD)
-# if defined(__LZO_MMODEL_HUGE)
-# define ACC_WANT_ACCLIB_HFREAD 1
-# else
-# define acc_hfread(f,b,s) (fread(b,1,s,f))
-# define acc_hfwrite(f,b,s) (fwrite(b,1,s,f))
-# endif
-#endif
-#if defined(WANT_LZO_UCLOCK)
-# define ACC_WANT_ACCLIB_PCLOCK 1
-# if 0 && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
-# define __ACCLIB_PCLOCK_USE_RDTSC 1
-# define ACC_WANT_ACCLIB_RDTSC 1
-# endif
+#if defined(WANT_LZO_PCLOCK)
+# define LZO_WANT_ACCLIB_PCLOCK 1
#endif
#if defined(WANT_LZO_WILDARGV)
-# define ACC_WANT_ACCLIB_WILDARGV 1
-#endif
-#if defined(__ACCLIB_PCLOCK_USE_PERFCTR)
-# include "src/fullacc.h"
-# define lzo_uclock_flush_cpu_cache(h,flags) acc_pclock_flush_cpu_cache(h,flags)
-#else
-# include "src/miniacc.h"
-#endif
-
-#if (__ACCLIB_REQUIRE_HMEMCPY_CH) && !defined(__ACCLIB_HMEMCPY_CH_INCLUDED)
-# define ACC_WANT_ACCLIB_HMEMCPY 1
-# include "src/miniacc.h"
+# define LZO_WANT_ACCLIB_WILDARGV 1
#endif
+#include "src/lzo_supp.h"
-
-/*************************************************************************
-// finally pull into the LZO namespace
-**************************************************************************/
-
-#undef lzo_malloc
-#undef lzo_free
-#undef lzo_fread
-#undef lzo_fwrite
#if defined(WANT_LZO_MALLOC)
-# define lzo_malloc(a) acc_halloc(a)
-# define lzo_free(a) acc_hfree(a)
+# define lzo_malloc(a) (malloc(a))
+# define lzo_free(a) (free(a))
#endif
#if defined(WANT_LZO_FREAD)
-# define lzo_fread(f,b,s) acc_hfread(f,b,s)
-# define lzo_fwrite(f,b,s) acc_hfwrite(f,b,s)
+# define lzo_fread(f,b,s) (fread(b,1,s,f))
+# define lzo_fwrite(f,b,s) (fwrite(b,1,s,f))
#endif
-#if defined(WANT_LZO_UCLOCK)
-# define lzo_uclock_handle_t acc_pclock_handle_t
-# define lzo_uclock_t acc_pclock_t
-# define lzo_uclock_open(a) acc_pclock_open_default(a)
-# define lzo_uclock_close(a) acc_pclock_close(a)
-# define lzo_uclock_read(a,b) acc_pclock_read(a,b)
-# define lzo_uclock_get_elapsed(a,b,c) acc_pclock_get_elapsed(a,b,c)
-#endif
-#if defined(WANT_LZO_WILDARGV)
-# define lzo_wildargv(a,b) acc_wildargv(a,b)
-#endif
-
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */
diff --git a/examples/precomp.c b/examples/precomp.c
index 10f4e7f..01b1e77 100644
--- a/examples/precomp.c
+++ b/examples/precomp.c
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -58,9 +46,11 @@
/* portability layer */
+static const char *progname = NULL;
#define WANT_LZO_MALLOC 1
#define WANT_LZO_FREAD 1
#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
#include "examples/portab.h"
@@ -79,18 +69,17 @@ int __lzo_cdecl_main main(int argc, char *argv[])
lzo_uint out_bufsize;
lzo_uint out_len = 0;
- lzo_bytep wrkmem;
- lzo_uint wrk_len;
+ lzo_voidp wrkmem;
+ lzo_uint wrkmem_size;
lzo_uint best_len;
int best_compress = -1;
lzo_uint orig_len;
- lzo_uint32 uncompressed_checksum;
- lzo_uint32 compressed_checksum;
+ lzo_uint32_t uncompressed_checksum;
+ lzo_uint32_t compressed_checksum;
- FILE *f;
- const char *progname = NULL;
+ FILE *fp;
const char *in_name = NULL;
const char *out_name = NULL;
long l;
@@ -100,7 +89,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
printf("\nLZO real-time data compression library (v%s, %s).\n",
lzo_version_string(), lzo_version_date());
- printf("Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+ printf("Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
progname = argv[0];
if (argc < 2 || argc > 3)
@@ -117,23 +106,21 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (lzo_init() != LZO_E_OK)
{
printf("internal error - lzo_init() failed !!!\n");
- printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n");
+ printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");
exit(1);
}
/*
* Step 2: allocate the work-memory
*/
- wrk_len = 1;
+ wrkmem_size = 1;
#ifdef USE_LZO1X
- if (wrk_len < LZO1X_999_MEM_COMPRESS)
- wrk_len = LZO1X_999_MEM_COMPRESS;
+ wrkmem_size = (LZO1X_999_MEM_COMPRESS > wrkmem_size) ? LZO1X_999_MEM_COMPRESS : wrkmem_size;
#endif
#ifdef USE_LZO1Y
- if (wrk_len < LZO1Y_999_MEM_COMPRESS)
- wrk_len = LZO1Y_999_MEM_COMPRESS;
+ wrkmem_size = (LZO1Y_999_MEM_COMPRESS > wrkmem_size) ? LZO1Y_999_MEM_COMPRESS : wrkmem_size;
#endif
- wrkmem = (lzo_bytep) lzo_malloc(wrk_len);
+ wrkmem = (lzo_voidp) xmalloc(wrkmem_size);
if (wrkmem == NULL)
{
printf("%s: out of memory\n", progname);
@@ -143,19 +130,19 @@ int __lzo_cdecl_main main(int argc, char *argv[])
/*
* Step 3: open the input file
*/
- f = fopen(in_name,"rb");
- if (f == NULL)
+ fp = fopen(in_name,"rb");
+ if (fp == NULL)
{
printf("%s: cannot open file %s\n", progname, in_name);
exit(1);
}
- fseek(f,0,SEEK_END);
- l = ftell(f);
- fseek(f,0,SEEK_SET);
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
if (l <= 0)
{
printf("%s: %s: empty file\n", progname, in_name);
- fclose(f);
+ fclose(fp); fp = NULL;
exit(1);
}
in_len = (lzo_uint) l;
@@ -165,16 +152,16 @@ int __lzo_cdecl_main main(int argc, char *argv[])
/*
* Step 4: allocate compression buffers and read the file
*/
- in = (lzo_bytep) lzo_malloc(in_len);
- out = (lzo_bytep) lzo_malloc(out_bufsize);
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(out_bufsize);
if (in == NULL || out == NULL)
{
printf("%s: out of memory\n", progname);
exit(1);
}
- in_len = (lzo_uint) lzo_fread(f,in,in_len);
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
printf("%s: loaded file %s: %ld bytes\n", progname, in_name, (long) in_len);
- fclose(f);
+ fclose(fp); fp = NULL;
/*
* Step 5: compute a checksum of the uncompressed data
@@ -183,7 +170,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
uncompressed_checksum = lzo_adler32(uncompressed_checksum,in,in_len);
/*
- * Step 6a: compress from `in' to `out' with LZO1X-999
+ * Step 6a: compress from 'in' to 'out' with LZO1X-999
*/
#ifdef USE_LZO1X
out_len = out_bufsize;
@@ -203,7 +190,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
#endif /* USE_LZO1X */
/*
- * Step 6b: compress from `in' to `out' with LZO1Y-999
+ * Step 6b: compress from 'in' to 'out' with LZO1Y-999
*/
#ifdef USE_LZO1Y
out_len = out_bufsize;
@@ -245,7 +232,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
assert(out_len == best_len);
/*
- * Step 9: optimize compressed data (compressed data is in `out' buffer)
+ * Step 9: optimize compressed data (compressed data is in 'out' buffer)
*/
#if 1
/* Optimization does not require any data in the buffer that will
@@ -287,13 +274,13 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (out_name && out_name[0])
{
printf("%s: writing to file %s\n", progname, out_name);
- f = fopen(out_name,"wb");
- if (f == NULL)
+ fp = fopen(out_name,"wb");
+ if (fp == NULL)
{
printf("%s: cannot open output file %s\n", progname, out_name);
exit(1);
}
- if (lzo_fwrite(f,out,out_len) != out_len || fclose(f) != 0)
+ if (lzo_fwrite(fp, out, out_len) != out_len || fclose(fp) != 0)
{
printf("%s: write error !!\n", progname);
exit(1);
@@ -339,7 +326,5 @@ int __lzo_cdecl_main main(int argc, char *argv[])
return 0;
}
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */
diff --git a/examples/precomp2.c b/examples/precomp2.c
index 44b066a..93dd8b5 100644
--- a/examples/precomp2.c
+++ b/examples/precomp2.c
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -65,7 +53,7 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
lzo_uint max_lazy,
lzo_uint nice_length,
lzo_uint max_chain,
- lzo_uint32 flags );
+ lzo_uint32_t flags );
LZO_EXTERN(int)
lzo1y_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
@@ -78,7 +66,7 @@ lzo1y_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
lzo_uint max_lazy,
lzo_uint nice_length,
lzo_uint max_chain,
- lzo_uint32 flags );
+ lzo_uint32_t flags );
#define USE_LZO1X 1
#define USE_LZO1Y 1
@@ -87,9 +75,11 @@ lzo1y_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
/* portability layer */
+static const char *progname = NULL;
#define WANT_LZO_MALLOC 1
#define WANT_LZO_FREAD 1
#define WANT_LZO_WILDARGV 1
+#define WANT_XMALLOC 1
#include "examples/portab.h"
@@ -103,7 +93,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
int lazy;
const int max_try_lazy = 5;
const lzo_uint big = 65536L; /* can result in very slow compression */
- const lzo_uint32 flags = 0x1;
+ const lzo_uint32_t flags = 0x1;
lzo_bytep in;
lzo_uint in_len;
@@ -112,19 +102,18 @@ int __lzo_cdecl_main main(int argc, char *argv[])
lzo_uint out_bufsize;
lzo_uint out_len = 0;
- lzo_bytep wrkmem;
- lzo_uint wrk_len;
+ lzo_voidp wrkmem;
+ lzo_uint wrkmem_size;
lzo_uint best_len;
int best_compress = -1;
int best_lazy = -1;
lzo_uint orig_len;
- lzo_uint32 uncompressed_checksum;
- lzo_uint32 compressed_checksum;
+ lzo_uint32_t uncompressed_checksum;
+ lzo_uint32_t compressed_checksum;
- FILE *f;
- const char *progname = NULL;
+ FILE *fp;
const char *in_name = NULL;
const char *out_name = NULL;
long l;
@@ -134,7 +123,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
printf("\nLZO real-time data compression library (v%s, %s).\n",
lzo_version_string(), lzo_version_date());
- printf("Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+ printf("Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
progname = argv[0];
if (argc < 2 || argc > 3)
@@ -151,23 +140,21 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (lzo_init() != LZO_E_OK)
{
printf("internal error - lzo_init() failed !!!\n");
- printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n");
+ printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");
exit(1);
}
/*
* Step 2: allocate the work-memory
*/
- wrk_len = 1;
+ wrkmem_size = 1;
#ifdef USE_LZO1X
- if (wrk_len < LZO1X_999_MEM_COMPRESS)
- wrk_len = LZO1X_999_MEM_COMPRESS;
+ wrkmem_size = (LZO1X_999_MEM_COMPRESS > wrkmem_size) ? LZO1X_999_MEM_COMPRESS : wrkmem_size;
#endif
#ifdef USE_LZO1Y
- if (wrk_len < LZO1Y_999_MEM_COMPRESS)
- wrk_len = LZO1Y_999_MEM_COMPRESS;
+ wrkmem_size = (LZO1Y_999_MEM_COMPRESS > wrkmem_size) ? LZO1Y_999_MEM_COMPRESS : wrkmem_size;
#endif
- wrkmem = (lzo_bytep) lzo_malloc(wrk_len);
+ wrkmem = (lzo_voidp) xmalloc(wrkmem_size);
if (wrkmem == NULL)
{
printf("%s: out of memory\n", progname);
@@ -177,19 +164,19 @@ int __lzo_cdecl_main main(int argc, char *argv[])
/*
* Step 3: open the input file
*/
- f = fopen(in_name,"rb");
- if (f == NULL)
+ fp = fopen(in_name,"rb");
+ if (fp == NULL)
{
printf("%s: cannot open file %s\n", progname, in_name);
exit(1);
}
- fseek(f,0,SEEK_END);
- l = ftell(f);
- fseek(f,0,SEEK_SET);
+ fseek(fp, 0, SEEK_END);
+ l = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
if (l <= 0)
{
printf("%s: %s: empty file\n", progname, in_name);
- fclose(f);
+ fclose(fp); fp = NULL;
exit(1);
}
in_len = (lzo_uint) l;
@@ -199,16 +186,16 @@ int __lzo_cdecl_main main(int argc, char *argv[])
/*
* Step 4: allocate compression buffers and read the file
*/
- in = (lzo_bytep) lzo_malloc(in_len);
- out = (lzo_bytep) lzo_malloc(out_bufsize);
+ in = (lzo_bytep) xmalloc(in_len);
+ out = (lzo_bytep) xmalloc(out_bufsize);
if (in == NULL || out == NULL)
{
printf("%s: out of memory\n", progname);
exit(1);
}
- in_len = (lzo_uint) lzo_fread(f,in,in_len);
+ in_len = (lzo_uint) lzo_fread(fp, in, in_len);
printf("%s: loaded file %s: %ld bytes\n", progname, in_name, (long) in_len);
- fclose(f);
+ fclose(fp); fp = NULL;
/*
* Step 5: compute a checksum of the uncompressed data
@@ -217,7 +204,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
uncompressed_checksum = lzo_adler32(uncompressed_checksum,in,in_len);
/*
- * Step 6a: compress from `in' to `out' with LZO1X-999
+ * Step 6a: compress from 'in' to 'out' with LZO1X-999
*/
#ifdef USE_LZO1X
for (lazy = 0; lazy <= max_try_lazy; lazy++)
@@ -244,7 +231,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
#endif /* USE_LZO1X */
/*
- * Step 6b: compress from `in' to `out' with LZO1Y-999
+ * Step 6b: compress from 'in' to 'out' with LZO1Y-999
*/
#ifdef USE_LZO1Y
for (lazy = 0; lazy <= max_try_lazy; lazy++)
@@ -297,7 +284,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
assert(out_len == best_len);
/*
- * Step 9: optimize compressed data (compressed data is in `out' buffer)
+ * Step 9: optimize compressed data (compressed data is in 'out' buffer)
*/
#if 1
/* Optimization does not require any data in the buffer that will
@@ -339,13 +326,13 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (out_name && out_name[0])
{
printf("%s: writing to file %s\n", progname, out_name);
- f = fopen(out_name,"wb");
- if (f == NULL)
+ fp = fopen(out_name,"wb");
+ if (fp == NULL)
{
printf("%s: cannot open output file %s\n", progname, out_name);
exit(1);
}
- if (lzo_fwrite(f,out,out_len) != out_len || fclose(f) != 0)
+ if (lzo_fwrite(fp, out, out_len) != out_len || fclose(fp) != 0)
{
printf("%s: write error !!\n", progname);
exit(1);
@@ -391,7 +378,5 @@ int __lzo_cdecl_main main(int argc, char *argv[])
return 0;
}
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */
diff --git a/examples/simple.c b/examples/simple.c
index 15611c9..42f814a 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -2,19 +2,7 @@
This file is part of the LZO real-time data compression library.
- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
@@ -53,12 +41,14 @@
#include "lzo/lzo1x.h"
/* portability layer */
+static const char *progname = NULL;
#define WANT_LZO_MALLOC 1
+#define WANT_XMALLOC 1
#include "examples/portab.h"
-/* We want to compress the data block at `in' with length `IN_LEN' to
- * the block at `out'. Because the input block may be incompressible,
+/* We want to compress the data block at 'in' with length 'IN_LEN' to
+ * the block at 'out'. Because the input block may be incompressible,
* we must provide a little more output space in case that compression
* is not possible.
*/
@@ -78,7 +68,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
int r;
lzo_bytep in;
lzo_bytep out;
- lzo_bytep wrkmem;
+ lzo_voidp wrkmem;
lzo_uint in_len;
lzo_uint out_len;
lzo_uint new_len;
@@ -88,7 +78,7 @@ int __lzo_cdecl_main main(int argc, char *argv[])
printf("\nLZO real-time data compression library (v%s, %s).\n",
lzo_version_string(), lzo_version_date());
- printf("Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
+ printf("Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n");
/*
* Step 1: initialize the LZO library
@@ -96,16 +86,16 @@ int __lzo_cdecl_main main(int argc, char *argv[])
if (lzo_init() != LZO_E_OK)
{
printf("internal error - lzo_init() failed !!!\n");
- printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable `-DLZO_DEBUG' for diagnostics)\n");
+ printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n");
return 4;
}
/*
* Step 2: allocate blocks and the work-memory
*/
- in = (lzo_bytep) lzo_malloc(IN_LEN);
- out = (lzo_bytep) lzo_malloc(OUT_LEN);
- wrkmem = (lzo_bytep) lzo_malloc(LZO1X_1_MEM_COMPRESS);
+ in = (lzo_bytep) xmalloc(IN_LEN);
+ out = (lzo_bytep) xmalloc(OUT_LEN);
+ wrkmem = (lzo_voidp) xmalloc(LZO1X_1_MEM_COMPRESS);
if (in == NULL || out == NULL || wrkmem == NULL)
{
printf("out of memory\n");
@@ -121,12 +111,12 @@ int __lzo_cdecl_main main(int argc, char *argv[])
lzo_memset(in,0,in_len);
/*
- * Step 4: compress from `in' to `out' with LZO1X-1
+ * Step 4: compress from 'in' to 'out' with LZO1X-1
*/
- r = lzo1x_1_compress(in,in_len,out,&out_len,wrkmem);
+ r = lzo1x_1_compress(in, in_len, out, &out_len, wrkmem);
if (r == LZO_E_OK)
printf("compressed %lu bytes into %lu bytes\n",
- (unsigned long) in_len, (unsigned long) out_len);
+ (unsigned long) in_len, (unsigned long) out_len);
else
{
/* this should NEVER happen */
@@ -141,13 +131,13 @@ int __lzo_cdecl_main main(int argc, char *argv[])
}
/*
- * Step 5: decompress again, now going from `out' to `in'
+ * Step 5: decompress again, now going from 'out' to 'in'
*/
new_len = in_len;
- r = lzo1x_decompress(out,out_len,in,&new_len,NULL);
+ r = lzo1x_decompress(out, out_len, in, &new_len, NULL);
if (r == LZO_E_OK && new_len == in_len)
printf("decompressed %lu bytes back into %lu bytes\n",
- (unsigned long) out_len, (unsigned long) in_len);
+ (unsigned long) out_len, (unsigned long) in_len);
else
{
/* this should NEVER happen */
@@ -162,7 +152,5 @@ int __lzo_cdecl_main main(int argc, char *argv[])
return 0;
}
-/*
-vi:ts=4:et
-*/
+/* vim:set ts=4 sw=4 et: */