diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-02-18 12:16:27 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-02-18 12:16:27 (GMT) |
commit | 5655953a2adcdcfe2f0d5599a52d36fbea405817 (patch) | |
tree | 352bf3ad7afc1b1277ad9218c33c8ad3aa06f852 | |
parent | 7ff7845b3a18a3e32fbf84f089f4a01ba9329274 (diff) | |
download | hdf5-5655953a2adcdcfe2f0d5599a52d36fbea405817.zip hdf5-5655953a2adcdcfe2f0d5599a52d36fbea405817.tar.gz hdf5-5655953a2adcdcfe2f0d5599a52d36fbea405817.tar.bz2 |
[svn-r6415] Purpose:
Code cleanup
Description:
Changed hard-coded magic number (32) for the maximum number of filters
in a filter pipeline to use a symbolic constant (H5Z_MAX_NFILTERS)
instead. This limit could (and probably should) be removed to allow an
unlimited number of filters in a pipeline.
Platforms tested:
FreeBSD 4.7 (sleipnir)
-rw-r--r-- | src/H5Opline.c | 6 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 2 | ||||
-rw-r--r-- | src/H5Z.c | 35 | ||||
-rw-r--r-- | src/H5Zprivate.h | 21 | ||||
-rw-r--r-- | src/H5Zpublic.h | 22 |
5 files changed, 58 insertions, 28 deletions
diff --git a/src/H5Opline.c b/src/H5Opline.c index a8d1426..3bdffe7 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -27,8 +27,10 @@ #include "H5MMprivate.h" #include "H5Opkg.h" /* Object header functions */ -/* Interface initialization */ +/* Pablo mask */ #define PABLO_MASK H5O_pline_mask + +/* Interface initialization */ static int interface_initialize_g = 0; #define INTERFACE_INIT NULL @@ -101,7 +103,7 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, if (version!=H5O_PLINE_VERSION) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message"); pline->nfilters = *p++; - if (pline->nfilters>32) + if (pline->nfilters>H5Z_MAX_NFILTERS) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter pipeline message has too many filters"); p += 6; /*reserved*/ pline->nalloc = pline->nfilters; diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index a938d12..438983e 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - #define H5P_PACKAGE /*suppress error about including H5Ppkg */ /* Private header files */ @@ -1,20 +1,27 @@ -/* - * Copyright (C) 1998-2001 NCSA - * All rights reserved. - * - * Programmer: Robb Matzke <matzke@llnl.gov> - * Thursday, April 16, 1998 - * - * Purpose: Functions for data filters. - */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include "H5private.h" #include "H5Eprivate.h" #include "H5MMprivate.h" #include "H5Oprivate.h" #include "H5Zprivate.h" -/* Interface initialization */ +/* Pablo mask */ #define PABLO_MASK H5Z_mask + +/* Interface initialization */ #define INTERFACE_INIT H5Z_init_interface static int interface_initialize_g = 0; static herr_t H5Z_init_interface (void); @@ -215,7 +222,7 @@ H5Z_register (H5Z_filter_t id, const char *comment, H5Z_func_t func) } if (i>=H5Z_table_used_g) { if (H5Z_table_used_g>=H5Z_table_alloc_g) { - size_t n = MAX(32, 2*H5Z_table_alloc_g); + size_t n = MAX(H5Z_MAX_NFILTERS, 2*H5Z_table_alloc_g); H5Z_class_t *table = H5MM_realloc(H5Z_table_g, n*sizeof(H5Z_class_t)); if (!table) @@ -394,13 +401,13 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, * Check filter limit. We do it here for early warnings although we may * decide to relax this restriction in the future. */ - if (pline->nfilters>=32) + if (pline->nfilters>=H5Z_MAX_NFILTERS) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline"); /* Allocate additional space in the pipeline if it's full */ if (pline->nfilters>=pline->nalloc) { H5O_pline_t x; - x.nalloc = MAX(32, 2*pline->nalloc); + x.nalloc = MAX(H5Z_MAX_NFILTERS, 2*pline->nalloc); x.filter = H5MM_realloc(pline->filter, x.nalloc*sizeof(x.filter[0])); if (NULL==x.filter) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline"); @@ -516,7 +523,7 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, unsigned flags, assert(nbytes && *nbytes>0); assert(buf_size && *buf_size>0); assert(buf && *buf); - assert(!pline || pline->nfilters<32); + assert(!pline || pline->nfilters<H5Z_MAX_NFILTERS); if (pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ for (i=pline->nfilters; i>0; --i) { diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index be87d9e..07cf38b 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -1,10 +1,21 @@ -/* - * Copyright (C) 1998-2001 NCSA - * All rights reserved. - * - * Programmer: Robb Matzke <matzke@llnl.gov> +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: Robb Matzke <matzke@llnl.gov> * Thursday, April 16, 1998 */ + #ifndef _H5Zprivate_H #define _H5Zprivate_H diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index 3acf54d..8893a88 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -1,10 +1,21 @@ -/* - * Copyright (C) 1998 NCSA - * All rights reserved. - * - * Programmer: Robb Matzke <matzke@llnl.gov> +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: Robb Matzke <matzke@llnl.gov> * Thursday, April 16, 1998 */ + #ifndef _H5Zpublic_H #define _H5Zpublic_H @@ -23,6 +34,7 @@ typedef int H5Z_filter_t; #define H5Z_FILTER_FLETCHER32 3 /*fletcher32 checksum of EDC */ #define H5Z_FILTER_RESERVED 256 /*filter ids below this value are reserved */ #define H5Z_FILTER_MAX 65535 /*maximum filter id */ +#define H5Z_MAX_NFILTERS 32 /* Maximum number of filters allowed in a pipeline (should probably be allowed to be an unlimited amount) */ /* Flags for filter definition */ #define H5Z_FLAG_DEFMASK 0x00ff /*definition flag mask */ |