summaryrefslogtreecommitdiffstats
path: root/iconvmodule
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>2002-02-02 20:26:53 +0000
committerMatt Wilson <msw@redhat.com>2002-02-02 20:26:53 +0000
commit59a39e1c6880bebf95e71ba726abece5777cbfe1 (patch)
treef3bf94cf0446f79f28b09808ca4d128d1ac920e1 /iconvmodule
parent24de9c701a0fe4adbd610fc6ba3bd47c48f9db5b (diff)
downloadanaconda-59a39e1c6880bebf95e71ba726abece5777cbfe1.tar.gz
anaconda-59a39e1c6880bebf95e71ba726abece5777cbfe1.tar.xz
anaconda-59a39e1c6880bebf95e71ba726abece5777cbfe1.zip
comments
Diffstat (limited to 'iconvmodule')
-rw-r--r--iconvmodule/iconvmodule.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/iconvmodule/iconvmodule.c b/iconvmodule/iconvmodule.c
index 31b4d20ed..c723511dd 100644
--- a/iconvmodule/iconvmodule.c
+++ b/iconvmodule/iconvmodule.c
@@ -76,7 +76,8 @@ Iconv_iconv(IconvObject *self, PyObject *args, PyObject* kwargs)
/* Perform the conversion. */
do {
- result = iconv(self->handle, (char **) &inptr, &inleft, &outptr, &outleft);
+ result = iconv(self->handle,
+ (char **) &inptr, &inleft, &outptr, &outleft);
if (result == (size_t) -1) {
if (errno == E2BIG) {
/* we ran out of space in outbuf, it needs to be bigger */
@@ -84,6 +85,9 @@ Iconv_iconv(IconvObject *self, PyObject *args, PyObject* kwargs)
/* a guess at how much more we need */
size_t curpos, extra = inleft * 2;
+ /* calculate the current position in the output buffer
+ so we can move outptr to the correct place in the realloced
+ space */
curpos = outptr - outbuf;
newbuf = realloc(outbuf, outptr - outbuf + extra);
if (newbuf == NULL) {
@@ -109,6 +113,7 @@ Iconv_iconv(IconvObject *self, PyObject *args, PyObject* kwargs)
}
} while (inleft > 0);
+ /* create a new string object from the converted buffer */
ret = PyString_FromStringAndSize(outbuf, outptr - outbuf);
free(outbuf);