patch-2.3.16 linux/net/irda/irias_object.c

Next file: linux/net/irda/irlan/irlan_client.c
Previous file: linux/net/irda/iriap.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.15/linux/net/irda/irias_object.c linux/net/irda/irias_object.c
@@ -6,10 +6,10 @@
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Thu Oct  1 22:50:04 1998
- * Modified at:   Mon Mar 22 13:22:35 1999
+ * Modified at:   Mon Jun 21 16:11:13 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  * 
- *     Copyright (c) 1998 Dag Brattli, All Rights Reserved.
+ *     Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
  *      
  *     This program is free software; you can redistribute it and/or 
  *     modify it under the terms of the GNU General Public License as 
@@ -35,9 +35,7 @@
 /*
  *  Used when a missing value needs to be returned
  */
-struct ias_value missing = {
-        IAS_MISSING,	0,	0,	{ 0 }
-};
+struct ias_value missing = { IAS_MISSING, 0, 0,	{0}};
 
 /*
  * Function strdup (str)
@@ -45,20 +43,20 @@
  *    My own kernel version of strdup!
  *
  */
-char *strdup( char *str)
+char *strdup(char *str)
 {
 	char *new_str;
 	
-	if ( str == NULL)
+	if (str == NULL)
 		return NULL;
 
-	ASSERT( strlen( str) < 64, return NULL;);
+	ASSERT(strlen( str) < 64, return NULL;);
 	
-        new_str = kmalloc( strlen( str)+1, GFP_ATOMIC);
-        if ( new_str == NULL)
+        new_str = kmalloc(strlen(str)+1, GFP_ATOMIC);
+        if (new_str == NULL)
 		return NULL;
 	
-	strcpy( new_str, str);
+	strcpy(new_str, str);
 	
 	return new_str;
 }
@@ -77,17 +75,17 @@
 
 	obj = (struct ias_object *) kmalloc( sizeof( struct ias_object), 
 					     GFP_ATOMIC);
-	if ( obj == NULL) {
-		DEBUG( 0, __FUNCTION__ "(), Unable to allocate object!\n");
+	if (obj == NULL) {
+		DEBUG(0, __FUNCTION__ "(), Unable to allocate object!\n");
 		return NULL;
 	}
-	memset( obj, 0, sizeof( struct ias_object));
+	memset(obj, 0, sizeof( struct ias_object));
 
 	obj->magic = IAS_OBJECT_MAGIC;
 	obj->name = strdup( name);
 	obj->id = id;
 
-	obj->attribs = hashbin_new( HB_LOCAL);
+	obj->attribs = hashbin_new(HB_LOCAL);
 	
 	return obj;
 }
@@ -98,59 +96,56 @@
  *    Delete given attribute and deallocate all its memory
  *
  */
-void __irias_delete_attrib( struct ias_attrib *attrib)
+void __irias_delete_attrib(struct ias_attrib *attrib)
 {
-	ASSERT( attrib != NULL, return;);
-	ASSERT( attrib->magic == IAS_ATTRIB_MAGIC, return;);
+	ASSERT(attrib != NULL, return;);
+	ASSERT(attrib->magic == IAS_ATTRIB_MAGIC, return;);
 
-	if ( attrib->name)
-		kfree( attrib->name);
+	if (attrib->name)
+		kfree(attrib->name);
 
-	irias_delete_value( attrib->value);
+	irias_delete_value(attrib->value);
 	attrib->magic = ~IAS_ATTRIB_MAGIC;
 	
-	kfree( attrib);
+	kfree(attrib);
 }
 
-/*
- * Function irias_delete_object (obj)
- *
- *    Remove object from hashbin and deallocate all attributes assosiated with
- *    with this object and the object itself
- *
- */
-void __irias_delete_object( struct ias_object *obj) 
+void __irias_delete_object(struct ias_object *obj)
 {
-	ASSERT( obj != NULL, return;);
-	ASSERT( obj->magic == IAS_OBJECT_MAGIC, return;);
-	
-	if ( obj->name)
-		kfree( obj->name);
+	ASSERT(obj != NULL, return;);
+	ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;);
+
+	if (obj->name)
+		kfree(obj->name);
 	
-	hashbin_delete( obj->attribs, (FREE_FUNC) __irias_delete_attrib);
+	hashbin_delete(obj->attribs, (FREE_FUNC) __irias_delete_attrib);
 	
 	obj->magic = ~IAS_OBJECT_MAGIC;
 	
-	kfree( obj);
+	kfree(obj);
 }
 
 /*
- * Function irias_remove_object (obj)
+ * Function irias_delete_object (obj)
  *
- *    Remove object with give name from the LM-IAS object database
+ *    Remove object from hashbin and deallocate all attributes assosiated with
+ *    with this object and the object itself
  *
  */
-void irias_delete_object( char *obj_name)
+int irias_delete_object(struct ias_object *obj) 
 {
-	struct ias_object *obj;
+	struct ias_object *node;
 
-	DEBUG( 4, __FUNCTION__ "()\n");
+	ASSERT(obj != NULL, return -1;);
+	ASSERT(obj->magic == IAS_OBJECT_MAGIC, return -1;);
 
-	ASSERT( obj_name != NULL, return;);
+	node = hashbin_remove(objects, 0, obj->name);
+	if (!node)
+		return 0; /* Already removed */
 
-	obj = hashbin_remove( objects, 0, obj_name);
+	__irias_delete_object(node);
 
-	__irias_delete_object( obj);
+	return 0;
 }
 
 /*
@@ -159,14 +154,14 @@
  *    Insert an object into the LM-IAS database
  *
  */
-void irias_insert_object( struct ias_object *obj)
+void irias_insert_object(struct ias_object *obj)
 {
-	DEBUG( 4, __FUNCTION__ "()\n");
+	DEBUG(4, __FUNCTION__ "()\n");
 	
-	ASSERT( obj != NULL, return;);
-	ASSERT( obj->magic == IAS_OBJECT_MAGIC, return;);
+	ASSERT(obj != NULL, return;);
+	ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;);
 	
-	hashbin_insert( objects, (QUEUE *) obj, 0, obj->name);
+	hashbin_insert(objects, (QUEUE *) obj, 0, obj->name);
 }
 
 /*
@@ -175,11 +170,11 @@
  *    Find object with given name
  *
  */
-struct ias_object *irias_find_object( char *name)
+struct ias_object *irias_find_object(char *name)
 {
-	ASSERT( name != NULL, return NULL;);
+	ASSERT(name != NULL, return NULL;);
 
-	return hashbin_find( objects, 0, name);
+	return hashbin_find(objects, 0, name);
 }
 
 /*
@@ -278,8 +273,6 @@
 {
 	struct ias_attrib *attrib;
 
-	DEBUG( 4, __FUNCTION__ "()\n");
-
 	ASSERT( obj != NULL, return;);
 	ASSERT( obj->magic == IAS_OBJECT_MAGIC, return;);
 	ASSERT( name != NULL, return;);
@@ -315,11 +308,6 @@
 {
 	struct ias_attrib *attrib;
 	
-	DEBUG( 0, __FUNCTION__ "()\n");
-	
-	DEBUG( 0, __FUNCTION__ ": name=%s\n", name);
-	DEBUG( 0, __FUNCTION__ ": len=%d\n", len);
-	
 	ASSERT( obj != NULL, return;);
 	ASSERT( obj->magic == IAS_OBJECT_MAGIC, return;);
 	
@@ -354,11 +342,6 @@
 {
 	struct ias_attrib *attrib;
 
-	DEBUG( 4, __FUNCTION__ "()\n");
-
-	DEBUG( 4, __FUNCTION__ ": name=%s\n", name);
-	DEBUG( 4, __FUNCTION__ ": name=%s\n", value);
-	
 	ASSERT( obj != NULL, return;);
 	ASSERT( obj->magic == IAS_OBJECT_MAGIC, return;);
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)