* psycopg/lobject*: const'ify the code.

This commit is contained in:
James Henstridge 2008-05-06 17:09:43 +08:00
parent 7d66c20edb
commit 2046ae34fb
4 changed files with 15 additions and 11 deletions

View File

@ -1,5 +1,7 @@
2008-05-06 James Henstridge <james@jamesh.id.au>
* psycopg/lobject*: const'ify the code.
* tests/test_lobject.py (LargeObjectTests): add more tests,
including behaviour on closed lobjects and stale lobjects.

View File

@ -42,7 +42,7 @@ typedef struct {
int closed; /* 1 if the lobject is closed */
int mode; /* numeric mode, tells if lobject was opened */
char *smode; /* string mode if lobject was opened */
const char *smode; /* string mode if lobject was opened */
long int mark; /* copied from conn->mark */
@ -53,12 +53,14 @@ typedef struct {
/* functions exported from lobject_int.c */
HIDDEN int lobject_open(lobjectObject *self, connectionObject *conn,
Oid oid, int mode, Oid new_oid, char *new_file);
Oid oid, int mode, Oid new_oid,
const char *new_file);
HIDDEN int lobject_unlink(lobjectObject *self);
HIDDEN int lobject_export(lobjectObject *self, char *filename);
HIDDEN int lobject_export(lobjectObject *self, const char *filename);
HIDDEN Py_ssize_t lobject_read(lobjectObject *self, char *buf, size_t len);
HIDDEN Py_ssize_t lobject_write(lobjectObject *self, char *buf, size_t len);
HIDDEN Py_ssize_t lobject_write(lobjectObject *self, const char *buf,
size_t len);
HIDDEN int lobject_seek(lobjectObject *self, int pos, int whence);
HIDDEN int lobject_tell(lobjectObject *self);
HIDDEN int lobject_close(lobjectObject *self);

View File

@ -45,7 +45,7 @@ collect_error(connectionObject *conn, char **error)
int
lobject_open(lobjectObject *self, connectionObject *conn,
Oid oid, int mode, Oid new_oid, char *new_file)
Oid oid, int mode, Oid new_oid, const char *new_file)
{
int retvalue = -1;
PGresult *pgres = NULL;
@ -198,7 +198,7 @@ lobject_unlink(lobjectObject *self)
/* lobject_write - write bytes to a lo */
Py_ssize_t
lobject_write(lobjectObject *self, char *buf, size_t len)
lobject_write(lobjectObject *self, const char *buf, size_t len)
{
Py_ssize_t written;
PGresult *pgres = NULL;
@ -301,7 +301,7 @@ lobject_tell(lobjectObject *self)
/* lobject_export - export to a local file */
int
lobject_export(lobjectObject *self, char *filename)
lobject_export(lobjectObject *self, const char *filename)
{
PGresult *pgres = NULL;
char *error = NULL;

View File

@ -74,7 +74,7 @@ static PyObject *
psyco_lobj_write(lobjectObject *self, PyObject *args)
{
int len, res=0;
char *buffer;
const char *buffer;
if (!PyArg_ParseTuple(args, "s#", &buffer, &len)) return NULL;
@ -191,7 +191,7 @@ psyco_lobj_unlink(lobjectObject *self, PyObject *args)
static PyObject *
psyco_lobj_export(lobjectObject *self, PyObject *args)
{
char *filename;
const char *filename;
if (!PyArg_ParseTuple(args, "s", &filename))
return NULL;
@ -244,7 +244,7 @@ static struct PyMemberDef lobjectObject_members[] = {
static int
lobject_setup(lobjectObject *self, connectionObject *conn,
Oid oid, int mode, Oid new_oid, char *new_file)
Oid oid, int mode, Oid new_oid, const char *new_file)
{
Dprintf("lobject_setup: init lobject object at %p", self);
@ -292,7 +292,7 @@ lobject_init(PyObject *obj, PyObject *args, PyObject *kwds)
{
Oid oid=InvalidOid, new_oid=InvalidOid;
int mode=0;
char *new_file = NULL;
const char *new_file = NULL;
PyObject *conn;
if (!PyArg_ParseTuple(args, "O|iiis",