Fix compilation of libmu_scm.
* libmu_scm/mu_body.c (mu_scm_body_free): Unref the stream. Return 0. (mu-body-read-line, mu-body-write): Use stringrefs. * libmu_scm/mu_mailbox.c (mu-mailbox-get-port): Use stringrefs. * libmu_scm/mu_message.c (mu-message-copy): Use stringrefs. Use mu_stream_copy instead of manually copying stream contents. (mu-message-get-port): Use stringrefs. * libmu_scm/mu_port.c (mu_port_free): Unref the stream.
Showing
4 changed files
with
18 additions
and
21 deletions
... | @@ -47,8 +47,9 @@ mu_scm_body_free (SCM body_smob) | ... | @@ -47,8 +47,9 @@ mu_scm_body_free (SCM body_smob) |
47 | struct mu_body *mbp = (struct mu_body *) SCM_CDR (body_smob); | 47 | struct mu_body *mbp = (struct mu_body *) SCM_CDR (body_smob); |
48 | if (mbp->buffer) | 48 | if (mbp->buffer) |
49 | free (mbp->buffer); | 49 | free (mbp->buffer); |
50 | mu_stream_unref (mbp->stream); | ||
50 | free (mbp); | 51 | free (mbp); |
51 | return sizeof (struct mu_body); | 52 | return 0; |
52 | } | 53 | } |
53 | 54 | ||
54 | static int | 55 | static int |
... | @@ -114,7 +115,7 @@ SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, | ... | @@ -114,7 +115,7 @@ SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, |
114 | 115 | ||
115 | if (!mbp->stream) | 116 | if (!mbp->stream) |
116 | { | 117 | { |
117 | status = mu_body_get_stream (mbp->body, &mbp->stream); | 118 | status = mu_body_get_streamref (mbp->body, &mbp->stream); |
118 | if (status) | 119 | if (status) |
119 | mu_scm_error (FUNC_NAME, status, | 120 | mu_scm_error (FUNC_NAME, status, |
120 | "Cannot get body stream", | 121 | "Cannot get body stream", |
... | @@ -158,7 +159,7 @@ SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0, | ... | @@ -158,7 +159,7 @@ SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0, |
158 | 159 | ||
159 | if (!mbp->stream) | 160 | if (!mbp->stream) |
160 | { | 161 | { |
161 | status = mu_body_get_stream (mbp->body, &mbp->stream); | 162 | status = mu_body_get_streamref (mbp->body, &mbp->stream); |
162 | if (status) | 163 | if (status) |
163 | mu_scm_error (FUNC_NAME, status, | 164 | mu_scm_error (FUNC_NAME, status, |
164 | "Cannot get body stream", SCM_BOOL_F); | 165 | "Cannot get body stream", SCM_BOOL_F); | ... | ... |
... | @@ -316,7 +316,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, | ... | @@ -316,7 +316,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, |
316 | SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); | 316 | SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); |
317 | SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME); | 317 | SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME); |
318 | mum = (struct mu_mailbox *) SCM_CDR (mbox); | 318 | mum = (struct mu_mailbox *) SCM_CDR (mbox); |
319 | status = mu_mailbox_get_stream (mum->mbox, &stream); | 319 | status = mu_mailbox_get_streamref (mum->mbox, &stream); |
320 | if (status) | 320 | if (status) |
321 | mu_scm_error (FUNC_NAME, status, | 321 | mu_scm_error (FUNC_NAME, status, |
322 | "Cannot get mailbox stream", | 322 | "Cannot get mailbox stream", | ... | ... |
... | @@ -195,14 +195,12 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, | ... | @@ -195,14 +195,12 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, |
195 | { | 195 | { |
196 | mu_message_t msg, newmsg; | 196 | mu_message_t msg, newmsg; |
197 | mu_stream_t in = NULL, out = NULL; | 197 | mu_stream_t in = NULL, out = NULL; |
198 | char buffer[512]; | ||
199 | size_t n; | ||
200 | int status; | 198 | int status; |
201 | 199 | ||
202 | SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME); | 200 | SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME); |
203 | msg = mu_scm_message_get (mesg); | 201 | msg = mu_scm_message_get (mesg); |
204 | 202 | ||
205 | status = mu_message_get_stream (msg, &in); | 203 | status = mu_message_get_streamref (msg, &in); |
206 | if (status) | 204 | if (status) |
207 | mu_scm_error (FUNC_NAME, status, | 205 | mu_scm_error (FUNC_NAME, status, |
208 | "Cannot get input stream from message ~A", | 206 | "Cannot get input stream from message ~A", |
... | @@ -213,7 +211,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, | ... | @@ -213,7 +211,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, |
213 | mu_scm_error (FUNC_NAME, status, | 211 | mu_scm_error (FUNC_NAME, status, |
214 | "Cannot create message", SCM_BOOL_F); | 212 | "Cannot create message", SCM_BOOL_F); |
215 | 213 | ||
216 | status = mu_message_get_stream (newmsg, &out); | 214 | status = mu_message_get_streamref (newmsg, &out); |
217 | if (status) | 215 | if (status) |
218 | { | 216 | { |
219 | mu_message_destroy (&newmsg, NULL); | 217 | mu_message_destroy (&newmsg, NULL); |
... | @@ -221,18 +219,14 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, | ... | @@ -221,18 +219,14 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, |
221 | "Cannot get output stream", SCM_BOOL_F); | 219 | "Cannot get output stream", SCM_BOOL_F); |
222 | } | 220 | } |
223 | 221 | ||
224 | mu_stream_seek (in, 0, MU_SEEK_SET, NULL); | 222 | status = mu_stream_copy (out, in, 0); |
225 | while ((status = mu_stream_read (in, buffer, sizeof (buffer) - 1, &n)) | 223 | mu_stream_destroy (&in); |
226 | == 0 | 224 | mu_stream_destroy (&out); |
227 | && n != 0) | 225 | if (status) |
228 | { | 226 | { |
229 | status = mu_stream_write (out, buffer, n, NULL); | 227 | mu_message_destroy (&newmsg, NULL); |
230 | if (status) | 228 | mu_scm_error (FUNC_NAME, status, |
231 | { | 229 | "Error writing to stream", SCM_BOOL_F); |
232 | mu_message_destroy (&newmsg, NULL); | ||
233 | mu_scm_error (FUNC_NAME, status, | ||
234 | "Error writing to stream", SCM_BOOL_F); | ||
235 | } | ||
236 | } | 230 | } |
237 | 231 | ||
238 | return mu_scm_message_create (SCM_BOOL_F, newmsg); | 232 | return mu_scm_message_create (SCM_BOOL_F, newmsg); |
... | @@ -905,7 +899,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, | ... | @@ -905,7 +899,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, |
905 | SCM_ASSERT (scm_is_bool (full), full, SCM_ARG3, FUNC_NAME); | 899 | SCM_ASSERT (scm_is_bool (full), full, SCM_ARG3, FUNC_NAME); |
906 | if (full == SCM_BOOL_T) | 900 | if (full == SCM_BOOL_T) |
907 | { | 901 | { |
908 | status = mu_message_get_stream (msg, &stream); | 902 | status = mu_message_get_streamref (msg, &stream); |
909 | if (status) | 903 | if (status) |
910 | mu_scm_error (FUNC_NAME, status, "Cannot get message stream", | 904 | mu_scm_error (FUNC_NAME, status, "Cannot get message stream", |
911 | SCM_BOOL_F); | 905 | SCM_BOOL_F); |
... | @@ -920,7 +914,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, | ... | @@ -920,7 +914,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, |
920 | if (status) | 914 | if (status) |
921 | mu_scm_error (FUNC_NAME, status, "Cannot get message body", | 915 | mu_scm_error (FUNC_NAME, status, "Cannot get message body", |
922 | SCM_BOOL_F); | 916 | SCM_BOOL_F); |
923 | status = mu_body_get_stream (body, &stream); | 917 | status = mu_body_get_streamref (body, &stream); |
924 | if (status) | 918 | if (status) |
925 | mu_scm_error (FUNC_NAME, status, "Cannot get message body stream", | 919 | mu_scm_error (FUNC_NAME, status, "Cannot get message body stream", |
926 | SCM_BOOL_F); | 920 | SCM_BOOL_F); | ... | ... |
... | @@ -151,6 +151,8 @@ mu_port_close (SCM port) | ... | @@ -151,6 +151,8 @@ mu_port_close (SCM port) |
151 | static scm_sizet | 151 | static scm_sizet |
152 | mu_port_free (SCM port) | 152 | mu_port_free (SCM port) |
153 | { | 153 | { |
154 | struct mu_port *mp = MU_PORT (port); | ||
155 | mu_stream_unref (mp->stream); | ||
154 | mu_port_close (port); | 156 | mu_port_close (port); |
155 | return 0; | 157 | return 0; |
156 | } | 158 | } | ... | ... |
-
Please register or sign in to post a comment