Skip to content

Remove unused LDAPberval helper functions #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions Modules/berval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,6 @@
#include "common.h"
#include "berval.h"

/*
* Converts a Python object into a data for a berval structure.
*
* New memory is allocated, and the content of the object is copied into it.
* Then the (pre-existing) berval structure's field are filled in with pointer
* and length data.
*
* The source object must implement the buffer interface, or be None.
* If the source object is None, bv->bv_val will be set to NULL and bv_len to 0.
* Otherwise, bv->bv_val will be non-NULL (even for zero-length data).
* This allows the caller to distinguish a None argument as something special.
*
* Returns 0 on failure, leaving *bv unchanged, and setting an error.
* Returns 1 on success: the berval must be freed with LDAPberval_release().
*/
int
LDAPberval_from_object(PyObject *obj, struct berval *bv)
{
const void *data;
char *datacp;
Py_ssize_t len;

if (PyNone_Check(obj)) {
bv->bv_len = 0;
bv->bv_val = NULL;
return 1;
}

if (!PyObject_AsReadBuffer(obj, &data, &len))
return 0;

datacp = PyMem_MALLOC(len ? len : 1);
if (!datacp) {
PyErr_NoMemory();
return 0;
}
memcpy(datacp, data, len);

bv->bv_len = len;
bv->bv_val = datacp;
return 1;
}

/*
* Returns true if the object could be used to initialize a berval structure
* with LDAPberval_from_object()
*/
int
LDAPberval_from_object_check(PyObject *obj)
{
return PyNone_Check(obj) ||
PyObject_CheckReadBuffer(obj);
}

/*
* Releases memory allocated by LDAPberval_from_object().
* Has no effect if the berval pointer is NULL or the berval data is NULL.
*/
void
LDAPberval_release(struct berval *bv) {
if (bv && bv->bv_val) {
PyMem_FREE(bv->bv_val);
bv->bv_len = 0;
bv->bv_val = NULL;
}
}

/*
* Copies out the data from a berval, and returns it as a new Python object,
* Returns None if the berval pointer is NULL.
Expand Down
3 changes: 0 additions & 3 deletions Modules/berval.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include "common.h"
#include "lber.h"

int LDAPberval_from_object(PyObject *obj, struct berval *bv);
int LDAPberval_from_object_check(PyObject *obj);
void LDAPberval_release(struct berval *bv);
PyObject *LDAPberval_to_object(const struct berval *bv);
PyObject *LDAPberval_to_unicode_object(const struct berval *bv);

Expand Down
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