Actual source code: cookie.c

  1: /*$Id: cookie.c,v 1.26 2001/03/23 23:20:38 balay Exp $*/

  3: #include "petsc.h"  /*I "petsc.h" I*/
  4: int PETSC_LARGEST_COOKIE = PETSC_LARGEST_COOKIE_PREDEFINED;

  6: /*@
  7:     PetscRegisterCookie - Registers a new cookie for use with a
  8:     newly created PETSc object class.  The user should pass in
  9:     a variable initialized to zero; then it will be assigned a cookie.
 10:     Repeated calls to this routine with the same variable will 
 11:     not change the cookie. 

 13:     Not Collective

 15:     Output Parameter:
 16: .   cookie - the cookie you have been assigned

 18:     Level: developer

 20:     Note:
 21:     The initial cookie variable MUST be set to zero on the
 22:     first call to this routine.

 24:     Concepts: cookie^getting new one

 26: @*/
 27: int PetscRegisterCookie(int *cookie)
 28: {
 30:   if (PETSC_LARGEST_COOKIE >= PETSC_LARGEST_COOKIE_ALLOWED) {
 31:     SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"You have used too many PETSc cookies");
 32:   }
 33:   if (!*cookie) *cookie = PETSC_LARGEST_COOKIE++;
 34:   return(0);
 35: }