/[pcre]/code/trunk/pcre32_refcount.c
ViewVC logotype

Diff of /code/trunk/pcre32_refcount.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

code/trunk/pcre_refcount.c revision 836 by ph10, Wed Dec 28 17:16:11 2011 UTC code/trunk/pcre32_refcount.c revision 1055 by chpe, Tue Oct 16 15:53:30 2012 UTC
# Line 37  POSSIBILITY OF SUCH DAMAGE. Line 37  POSSIBILITY OF SUCH DAMAGE.
37  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
38  */  */
39    
40    /* Generate code with 32 bit character support. */
41    #define COMPILE_PCRE32
42    
43  /* This module contains the external function pcre_refcount(), which is an  #include "pcre_refcount.c"
 auxiliary function that can be used to maintain a reference count in a compiled  
 pattern data block. This might be helpful in applications where the block is  
 shared by different users. */  
44    
45    /* End of pcre32_refcount.c */
 #ifdef HAVE_CONFIG_H  
 #include "config.h"  
 #endif  
   
 #include "pcre_internal.h"  
   
   
 /*************************************************  
 *           Maintain reference count             *  
 *************************************************/  
   
 /* The reference count is a 16-bit field, initialized to zero. It is not  
 possible to transfer a non-zero count from one host to a different host that  
 has a different byte order - though I can't see why anyone in their right mind  
 would ever want to do that!  
   
 Arguments:  
   argument_re   points to compiled code  
   adjust        value to add to the count  
   
 Returns:        the (possibly updated) count value (a non-negative number), or  
                 a negative error number  
 */  
   
 #ifdef COMPILE_PCRE8  
 PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  
 pcre_refcount(pcre *argument_re, int adjust)  
 #else  
 PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  
 pcre_refcount(pcre *argument_re, int adjust)  
 #endif  
 {  
 real_pcre *re = (real_pcre *)argument_re;  
 if (re == NULL) return PCRE_ERROR_NULL;  
 if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;  
 if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;  
 re->ref_count = (-adjust > re->ref_count)? 0 :  
                 (adjust + re->ref_count > 65535)? 65535 :  
                 re->ref_count + adjust;  
 return re->ref_count;  
 }  
   
 /* End of pcre_refcount.c */  

Legend:
Removed from v.836  
changed lines
  Added in v.1055

  ViewVC Help
Powered by ViewVC 1.1.5