User Tools

Site Tools


programming:python:pyradix_search_all_patch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
programming:python:pyradix_search_all_patch [2008/07/05 21:26]
crustymonkey
programming:python:pyradix_search_all_patch [2008/07/05 22:10] (current)
crustymonkey
Line 13: Line 13:
 Usage: Usage:
 <code> <code>
-Radix.search_all_containing(<network>) -> [ <node> , <node> , ...]+Radix.search_all_containing(<network>) -> [ <node> , <node> , ... ]
 </code> </code>
 <code python> <code python>
Line 61: Line 61:
 Here is the code for the patch, followed by a link to the file. Here is the code for the patch, followed by a link to the file.
 <code> <code>
---- radix_python.c  2008-07-05 15:22:55.000000000 -0500 +--- radix_python.c  2008-07-05 17:08:51.000000000 -0500 
-+++ radix_python.c.new  2008-07-05 15:19:03.000000000 -0500 ++++ radix_python.c.new  2008-07-05 17:08:11.000000000 -0500 
-@@ -453,6 +453,53 @@+@@ -453,6 +453,52 @@
     return (PyObject *)node_obj;     return (PyObject *)node_obj;
  }  }
Line 89: Line 89:
 +   long prefixlen = -1; +   long prefixlen = -1;
 +   int packlen = -1; +   int packlen = -1;
 ++   if ((node_list = PyList_New(0)) == NULL)
 ++       return NULL;
 + +
-+   if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|sls#:search_best", keywords,++   if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|sls#:search_all_containing", keywords,
 +       &addr, &prefixlen, &packed, &packlen)) +       &addr, &prefixlen, &packed, &packlen))
 +       return NULL; +       return NULL;
Line 99: Line 101:
 +       node->data == NULL) { +       node->data == NULL) {
 +       Deref_Prefix(prefix); +       Deref_Prefix(prefix);
-+       Py_INCREF(Py_None); ++       return node_list;
-+       return Py_None;+
 +   } +   }
 +   Deref_Prefix(prefix); +   Deref_Prefix(prefix);
-+   node_list = PyList_New(0); ++   PyList_Append(node_list , (PyObject *)node->data);
-+   node_obj = node->data; +
-+   PyList_Append(node_list , (PyObject *)node_obj);+
 +   while ((parent = node->parent) != NULL) { +   while ((parent = node->parent) != NULL) {
-      node_obj = parent->data; +       if (parent->data != NULL) 
-      PyList_Append(node_list , (PyObject *)node_obj);+           PyList_Append(node_list , (PyObject *)parent->data);
 +       node = parent; +       node = parent;
 +   } +   }
Line 117: Line 116:
  "Radix.nodes(prefix) -> List of RadixNode\n\  "Radix.nodes(prefix) -> List of RadixNode\n\
  \n\  \n\
-@@ -640,6 +687,7 @@+@@ -640,6 +686,7 @@
     {"delete",  (PyCFunction)Radix_delete,  METH_VARARGS|METH_KEYWORDS, Radix_delete_doc    },     {"delete",  (PyCFunction)Radix_delete,  METH_VARARGS|METH_KEYWORDS, Radix_delete_doc    },
     {"search_exact",(PyCFunction)Radix_search_exact,METH_VARARGS|METH_KEYWORDS, Radix_search_exact_doc  },     {"search_exact",(PyCFunction)Radix_search_exact,METH_VARARGS|METH_KEYWORDS, Radix_search_exact_doc  },
programming/python/pyradix_search_all_patch.1215293175.txt.gz · Last modified: 2008/07/05 21:26 by crustymonkey