mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-04 03:27:00 -05:00 
			
		
		
		
	Allow detaching handles
This commit is contained in:
		
							parent
							
								
									40de844650
								
							
						
					
					
						commit
						f5f7a44a47
					
				@ -55,6 +55,13 @@ Handle_dealloc(Handle *self) {
 | 
				
			|||||||
	Py_CLEAR(self->associated_name);
 | 
						Py_CLEAR(self->associated_name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static PyObject*
 | 
				
			||||||
 | 
					Handle_detach(Handle *self) {
 | 
				
			||||||
 | 
						void *h = self->handle;
 | 
				
			||||||
 | 
						self->handle = NULL;
 | 
				
			||||||
 | 
						return PyLong_FromVoidPtr(h);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static PyObject*
 | 
					static PyObject*
 | 
				
			||||||
Handle_as_int(Handle * self) {
 | 
					Handle_as_int(Handle * self) {
 | 
				
			||||||
	return PyLong_FromVoidPtr(self->handle);
 | 
						return PyLong_FromVoidPtr(self->handle);
 | 
				
			||||||
@ -128,6 +135,7 @@ Handle_close(Handle *self) {
 | 
				
			|||||||
#define M(name, args) {#name, (PyCFunction)Handle_##name, args, ""}
 | 
					#define M(name, args) {#name, (PyCFunction)Handle_##name, args, ""}
 | 
				
			||||||
static PyMethodDef Handle_methods[] = {
 | 
					static PyMethodDef Handle_methods[] = {
 | 
				
			||||||
	M(close, METH_NOARGS),
 | 
						M(close, METH_NOARGS),
 | 
				
			||||||
 | 
						M(detach, METH_NOARGS),
 | 
				
			||||||
    {NULL, NULL, 0, NULL}
 | 
					    {NULL, NULL, 0, NULL}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#undef M
 | 
					#undef M
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user