home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Magazine / UsingPDF / GhostScript / source / gs5.10 / gsfunc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-01  |  2.2 KB  |  69 lines

  1. /* Copyright (C) 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gsfunc.c */
  20. /* Generic Function support */
  21. #include "gx.h"
  22. #include "gserrors.h"
  23. #include "gxfunc.h"
  24.  
  25. /* GC descriptor */
  26. public_st_function();
  27.  
  28. /* Generic free_params implementation. */
  29. void
  30. fn_common_free_params(gs_function_params_t *params, gs_memory_t *mem)
  31. {    gs_free_object(mem, (void *)params->Range, "Range"); /* break const */
  32.     gs_free_object(mem, (void *)params->Domain, "Domain"); /* break const */
  33. }
  34.  
  35. /* Generic free implementation. */
  36. void
  37. fn_common_free(gs_function_t *pfn, bool free_params, gs_memory_t *mem)
  38. {    if ( free_params )
  39.       gs_function_free_params(pfn, mem);
  40.     gs_free_object(mem, pfn, "fn_xxx_free");
  41. }
  42.  
  43. /* Free an array of subsidiary Functions. */
  44. void
  45. fn_free_functions(gs_function_t **Functions, int count, gs_memory_t *mem)
  46. {    int i;
  47.  
  48.     for ( i = count; --i >= 0; )
  49.       gs_function_free(Functions[i], true, mem);
  50.     gs_free_object(mem, Functions, "Functions");
  51. }
  52.  
  53. /* Check the values of m, n, Domain, and (if supplied) Range. */
  54. int
  55. fn_check_mnDR_proc(const gs_function_params_t *params, int m, int n)
  56. {    int i;
  57.  
  58.     if ( m <= 0 || n <= 0 )
  59.       return_error(gs_error_rangecheck);
  60.     for ( i = 0; i < m; ++i )
  61.       if ( params->Domain[2 * i] > params->Domain[2 * i + 1] )
  62.         return_error(gs_error_rangecheck);
  63.     if ( params->Range != 0 )
  64.       for ( i = 0; i < n; ++i )
  65.         if ( params->Range[2 * i] > params->Range[2 * i + 1] )
  66.           return_error(gs_error_rangecheck);
  67.     return 0;
  68. }
  69.