Registry: Recursive key delete patch

Jason McMullan jmcmullan at linuxcare.com
Wed Oct 24 13:52:25 CDT 2001


	This patch permits the recursive deletion of registry
keys that also contain subkeys. Applies to latest CVS wine.

Index: server/registry.c
===================================================================
RCS file: /home/wine/wine/server/registry.c,v
retrieving revision 1.33
diff -u -r1.33 registry.c
--- wine/server/registry.c	2001/04/10 21:18:17	1.33
+++ wine/server/registry.c	2001/10/24 17:27:43
@@ -642,8 +642,8 @@
 /* delete a key and its values */
 static void delete_key( struct key *key )
 {
-    int index;
-    struct key *parent;
+    int index, skey, skey_len;
+    struct key *parent,**skeys;
 
     /* must find parent and index */
     if (key->flags & KEY_ROOT)
@@ -659,6 +659,17 @@
     for (index = 0; index <= parent->last_subkey; index++)
         if (parent->subkeys[index] == key) break;
     assert( index <= parent->last_subkey );
+
+	/* Recusively delete keys */
+    if (key->last_subkey >= 0 ) {
+        skey_len = key->last_subkey+1;
+        skeys = (struct key **)malloc(sizeof(struct key *)*skey_len);
+        memcpy(skeys,key->subkeys,sizeof(struct key *)*skey_len);
+        for (skey = 0; skey < skey_len; skey++) {
+            delete_key(skeys[skey]);
+        }
+        free(skeys);
+    }
 
     /* we can only delete a key that has no subkeys (FIXME) */
     if ((key->flags & KEY_ROOT) || (key->last_subkey >= 0))

-- 
Jason McMullan, Senior Linux Consultant, Linuxcare, Inc.
412.422.8077 tel, 412.656.3519 cell, 208.694.9206 fax
jmcmullan at linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.




More information about the wine-patches mailing list