| 
				
			 | 
			
			
				
				@@ -31,18 +31,16 @@ FILE_LICENCE ( GPL2_OR_LATER ); 
			 | 
		
		
	
		
			
			| 
				31
			 | 
			
				31
			 | 
			
			
				
				  * Increment reference count 
			 | 
		
		
	
		
			
			| 
				32
			 | 
			
				32
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				33
			 | 
			
				33
			 | 
			
			
				
				  * @v refcnt		Reference counter, or NULL 
			 | 
		
		
	
		
			
			| 
				34
			 | 
			
				
			 | 
			
			
				
				- * @ret refcnt		Reference counter 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				34
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				35
			 | 
			
			
				
				  * If @c refcnt is NULL, no action is taken. 
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				36
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				
				-struct refcnt * ref_get ( struct refcnt *refcnt ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				
				+void ref_increment ( struct refcnt *refcnt ) { 
			 | 
		
		
	
		
			
			| 
				39
			 | 
			
				38
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				40
			 | 
			
				39
			 | 
			
			
				
				 	if ( refcnt ) { 
			 | 
		
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				
				-		refcnt->refcnt++; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				
				+		refcnt->count++; 
			 | 
		
		
	
		
			
			| 
				42
			 | 
			
				41
			 | 
			
			
				
				 		DBGC2 ( refcnt, "REFCNT %p incremented to %d\n", 
			 | 
		
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				
				-			refcnt, refcnt->refcnt ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				
				+			refcnt, refcnt->count ); 
			 | 
		
		
	
		
			
			| 
				44
			 | 
			
				43
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				45
			 | 
			
				
			 | 
			
			
				
				-	return refcnt; 
			 | 
		
		
	
		
			
			| 
				46
			 | 
			
				44
			 | 
			
			
				
				 } 
			 | 
		
		
	
		
			
			| 
				47
			 | 
			
				45
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				48
			 | 
			
				46
			 | 
			
			
				
				 /** 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -55,18 +53,28 @@ struct refcnt * ref_get ( struct refcnt *refcnt ) { 
			 | 
		
		
	
		
			
			| 
				55
			 | 
			
				53
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				56
			 | 
			
				54
			 | 
			
			
				
				  * If @c refcnt is NULL, no action is taken. 
			 | 
		
		
	
		
			
			| 
				57
			 | 
			
				55
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				
				-void ref_put ( struct refcnt *refcnt ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				
				+void ref_decrement ( struct refcnt *refcnt ) { 
			 | 
		
		
	
		
			
			| 
				59
			 | 
			
				57
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				60
			 | 
			
				58
			 | 
			
			
				
				 	if ( ! refcnt ) 
			 | 
		
		
	
		
			
			| 
				61
			 | 
			
				59
			 | 
			
			
				
				 		return; 
			 | 
		
		
	
		
			
			| 
				62
			 | 
			
				60
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				
				-	refcnt->refcnt--; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				
				+	refcnt->count--; 
			 | 
		
		
	
		
			
			| 
				64
			 | 
			
				62
			 | 
			
			
				
				 	DBGC2 ( refcnt, "REFCNT %p decremented to %d\n", 
			 | 
		
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				
				-		refcnt, refcnt->refcnt ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				
				+		refcnt, refcnt->count ); 
			 | 
		
		
	
		
			
			| 
				66
			 | 
			
				64
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				
				-	if ( refcnt->refcnt >= 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				
				+	if ( refcnt->count >= 0 ) 
			 | 
		
		
	
		
			
			| 
				68
			 | 
			
				66
			 | 
			
			
				
				 		return; 
			 | 
		
		
	
		
			
			| 
				69
			 | 
			
				67
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				
				+	if ( refcnt->count < -1 ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				
				+		DBGC ( refcnt, "REFCNT %p decremented too far (%d)!\n", 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				
				+		       refcnt, refcnt->count ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				
				+		/* Avoid multiple calls to free(), which typically 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				
				+		 * result in memory corruption that is very hard to 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				
				+		 * track down. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				
				+		 */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				
				+		return; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				
				+	} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				70
			 | 
			
				78
			 | 
			
			
				
				 	if ( refcnt->free ) { 
			 | 
		
		
	
		
			
			| 
				71
			 | 
			
				79
			 | 
			
			
				
				 		DBGC ( refcnt, "REFCNT %p being freed via method %p\n", 
			 | 
		
		
	
		
			
			| 
				72
			 | 
			
				80
			 | 
			
			
				
				 		       refcnt, refcnt->free ); 
			 |