summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Henstridge <james@jamesh.id.au>2008-05-06 17:09:43 +0800
committerJames Henstridge <james@jamesh.id.au>2008-05-06 17:09:43 +0800
commit2046ae34fbeb32a6ed38fa829df809c34aa4344f (patch)
tree0ecf381f3a0085571b94ba27275694f932671167
parent7d66c20edb087e175064a638cc90f2a644e2f93a (diff)
downloadpsycopg2-2046ae34fbeb32a6ed38fa829df809c34aa4344f.tar.gz
* psycopg/lobject*: const'ify the code.
-rw-r--r--ChangeLog2
-rw-r--r--psycopg/lobject.h10
-rw-r--r--psycopg/lobject_int.c6
-rw-r--r--psycopg/lobject_type.c8
4 files changed, 15 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c13255..d755d18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/psycopg/lobject.h b/psycopg/lobject.h
index 9f6bce3..d6dd979 100644
--- a/psycopg/lobject.h
+++ b/psycopg/lobject.h
@@ -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);
diff --git a/psycopg/lobject_int.c b/psycopg/lobject_int.c
index 476f236..13f30bd 100644
--- a/psycopg/lobject_int.c
+++ b/psycopg/lobject_int.c
@@ -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;
diff --git a/psycopg/lobject_type.c b/psycopg/lobject_type.c
index 690e4b6..e191bdf 100644
--- a/psycopg/lobject_type.c
+++ b/psycopg/lobject_type.c
@@ -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",