Mercurial > hg > xemacs-beta
comparison src/lstream.c @ 456:e7ef97881643 r21-2-43
Import from CVS: tag r21-2-43
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:41:24 +0200 |
parents | 576fb035e263 |
children | 0784d089fdc9 |
comparison
equal
deleted
inserted
replaced
455:5b97c1cd6ed0 | 456:e7ef97881643 |
---|---|
177 /* Just close. */ | 177 /* Just close. */ |
178 Lstream_close (lstr); | 178 Lstream_close (lstr); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 inline static size_t | |
183 aligned_sizeof_lstream (size_t lstream_type_specific_size) | |
184 { | |
185 return ALIGN_SIZE (offsetof (Lstream, data) + lstream_type_specific_size, | |
186 ALIGNOF (max_align_t)); | |
187 } | |
188 | |
182 static size_t | 189 static size_t |
183 sizeof_lstream (const void *header) | 190 sizeof_lstream (const void *header) |
184 { | 191 { |
185 const Lstream *lstr = (const Lstream *) header; | 192 return aligned_sizeof_lstream (((const Lstream *) header)->imp->size); |
186 return sizeof (*lstr) + lstr->imp->size - 1; | |
187 } | 193 } |
188 | 194 |
189 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("stream", lstream, | 195 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("stream", lstream, |
190 mark_lstream, print_lstream, | 196 mark_lstream, print_lstream, |
191 finalize_lstream, 0, 0, 0, | 197 finalize_lstream, 0, 0, 0, |
229 if (i == lstream_type_count) | 235 if (i == lstream_type_count) |
230 { | 236 { |
231 assert (lstream_type_count < countof (lstream_types)); | 237 assert (lstream_type_count < countof (lstream_types)); |
232 lstream_types[lstream_type_count] = imp; | 238 lstream_types[lstream_type_count] = imp; |
233 Vlstream_free_list[lstream_type_count] = | 239 Vlstream_free_list[lstream_type_count] = |
234 make_lcrecord_list (sizeof (*p) + imp->size - 1, | 240 make_lcrecord_list (aligned_sizeof_lstream (imp->size), |
235 &lrecord_lstream); | 241 &lrecord_lstream); |
236 lstream_type_count++; | 242 lstream_type_count++; |
237 } | 243 } |
238 | 244 |
239 p = XLSTREAM (allocate_managed_lcrecord (Vlstream_free_list[i])); | 245 p = XLSTREAM (allocate_managed_lcrecord (Vlstream_free_list[i])); |
240 /* Zero it out, except the header. */ | 246 /* Zero it out, except the header. */ |
241 memset ((char *) p + sizeof (p->header), 0, | 247 memset ((char *) p + sizeof (p->header), '\0', |
242 sizeof (*p) - sizeof (p->header) + imp->size - 1); | 248 aligned_sizeof_lstream (imp->size) - sizeof (p->header)); |
243 p->imp = imp; | 249 p->imp = imp; |
244 Lstream_set_buffering (p, LSTREAM_BLOCK_BUFFERED, 0); | 250 Lstream_set_buffering (p, LSTREAM_BLOCK_BUFFERED, 0); |
245 p->flags = LSTREAM_FL_IS_OPEN; | 251 p->flags = LSTREAM_FL_IS_OPEN; |
246 | 252 |
247 /* convert mode (one of "r", "w", "rc", "wc") to p->flags */ | 253 /* convert mode (one of "r", "w", "rc", "wc") to p->flags */ |