aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/net-snmp-devel/files/patch-cache_handler.c
blob: 0bcb75fb057b99aca6f4b341cd9b75311b8c90b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- agent/helpers/cache_handler.c.orig	2009-01-25 22:40:13.000000000 +0900
+++ agent/helpers/cache_handler.c	2009-01-25 22:44:30.000000000 +0900
@@ -173,6 +173,31 @@
     return cache;
 }
 
+/** frees a cache
+ */
+int
+netsnmp_cache_free(netsnmp_cache *cache)
+{
+    netsnmp_cache  *pos;
+
+    if (NULL == cache)
+        return SNMPERR_SUCCESS;
+
+    for (pos = cache_head; pos; pos = pos->next) {
+        if (pos == cache) {
+            snmp_log(LOG_WARNING, "not freeing cache (still in list)\n");
+            return SNMP_ERR_GENERR;
+        }
+    }
+
+    if (cache->rootoid)
+        free(cache->rootoid);
+
+    free(cache);
+
+    return SNMPERR_SUCCESS;
+}
+
 /** callback function to call cache load function */
 static void
 _timer_reload(unsigned int regNo, void *clientargs)