Skip to content

Commit cc64929

Browse files
committed
Remove unused LDAPberval helper functions
LDAPberval_from_object(), LDAPberval_from_object_check(), and LDAPberval_release() were introduced in 20bee65 but never used. Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent 4c9c526 commit cc64929

File tree

2 files changed

+0
-70
lines changed

2 files changed

+0
-70
lines changed

Modules/berval.c

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,6 @@
33
#include "common.h"
44
#include "berval.h"
55

6-
/*
7-
* Converts a Python object into a data for a berval structure.
8-
*
9-
* New memory is allocated, and the content of the object is copied into it.
10-
* Then the (pre-existing) berval structure's field are filled in with pointer
11-
* and length data.
12-
*
13-
* The source object must implement the buffer interface, or be None.
14-
* If the source object is None, bv->bv_val will be set to NULL and bv_len to 0.
15-
* Otherwise, bv->bv_val will be non-NULL (even for zero-length data).
16-
* This allows the caller to distinguish a None argument as something special.
17-
*
18-
* Returns 0 on failure, leaving *bv unchanged, and setting an error.
19-
* Returns 1 on success: the berval must be freed with LDAPberval_release().
20-
*/
21-
int
22-
LDAPberval_from_object(PyObject *obj, struct berval *bv)
23-
{
24-
const void *data;
25-
char *datacp;
26-
Py_ssize_t len;
27-
28-
if (PyNone_Check(obj)) {
29-
bv->bv_len = 0;
30-
bv->bv_val = NULL;
31-
return 1;
32-
}
33-
34-
if (!PyObject_AsReadBuffer(obj, &data, &len))
35-
return 0;
36-
37-
datacp = PyMem_MALLOC(len ? len : 1);
38-
if (!datacp) {
39-
PyErr_NoMemory();
40-
return 0;
41-
}
42-
memcpy(datacp, data, len);
43-
44-
bv->bv_len = len;
45-
bv->bv_val = datacp;
46-
return 1;
47-
}
48-
49-
/*
50-
* Returns true if the object could be used to initialize a berval structure
51-
* with LDAPberval_from_object()
52-
*/
53-
int
54-
LDAPberval_from_object_check(PyObject *obj)
55-
{
56-
return PyNone_Check(obj) ||
57-
PyObject_CheckReadBuffer(obj);
58-
}
59-
60-
/*
61-
* Releases memory allocated by LDAPberval_from_object().
62-
* Has no effect if the berval pointer is NULL or the berval data is NULL.
63-
*/
64-
void
65-
LDAPberval_release(struct berval *bv) {
66-
if (bv && bv->bv_val) {
67-
PyMem_FREE(bv->bv_val);
68-
bv->bv_len = 0;
69-
bv->bv_val = NULL;
70-
}
71-
}
72-
736
/*
747
* Copies out the data from a berval, and returns it as a new Python object,
758
* Returns None if the berval pointer is NULL.

Modules/berval.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include "common.h"
77
#include "lber.h"
88

9-
int LDAPberval_from_object(PyObject *obj, struct berval *bv);
10-
int LDAPberval_from_object_check(PyObject *obj);
11-
void LDAPberval_release(struct berval *bv);
129
PyObject *LDAPberval_to_object(const struct berval *bv);
1310
PyObject *LDAPberval_to_unicode_object(const struct berval *bv);
1411

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