Skip to content

Commit 6f53205

Browse files
tiranencukou
authored andcommitted
Modules: Use LDAPControls_to_List in LDAP_get_option instead of inlining it
1 parent c5ad802 commit 6f53205

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

Modules/options.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ LDAP_get_option(LDAPObject *self, int option)
180180
struct timeval *tv;
181181
LDAPAPIInfo apiinfo;
182182
LDAPControl **lcs;
183-
LDAPControl *lc;
184183
char *strval;
185-
PyObject *extensions, *v, *tup;
186-
Py_ssize_t i, num_extensions, num_controls;
184+
PyObject *extensions, *v;
185+
Py_ssize_t i, num_extensions;
187186
LDAP *ld;
188187

189188
ld = self ? self->ldap : NULL;
@@ -352,27 +351,8 @@ LDAP_get_option(LDAPObject *self, int option)
352351
if (res != LDAP_OPT_SUCCESS)
353352
return option_error(res, "ldap_get_option");
354353

355-
if (lcs == NULL)
356-
return PyList_New(0);
357-
358-
/* Get the number of controls */
359-
num_controls = 0;
360-
while (lcs[num_controls])
361-
num_controls++;
362-
363-
/* We'll build a list of controls, with each control a tuple */
364-
v = PyList_New(num_controls);
365-
for (i = 0; i < num_controls; i++) {
366-
lc = lcs[i];
367-
tup = Py_BuildValue("(sbs)",
368-
lc->ldctl_oid,
369-
lc->ldctl_iscritical,
370-
lc->ldctl_value.bv_val);
371-
PyList_SET_ITEM(v, i, tup);
372-
}
373-
354+
v = LDAPControls_to_List(lcs);
374355
ldap_controls_free(lcs);
375-
376356
return v;
377357

378358
default:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy