Mercurial > hg > xemacs-beta
comparison src/opaque.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 | abe6d1db359e |
children | b39c14581166 |
comparison
equal
deleted
inserted
replaced
455:5b97c1cd6ed0 | 456:e7ef97881643 |
---|---|
50 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (opaque, size=%lu) 0x%lx>", | 50 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (opaque, size=%lu) 0x%lx>", |
51 (long)(p->size), (unsigned long) p); | 51 (long)(p->size), (unsigned long) p); |
52 write_c_string (buf, printcharfun); | 52 write_c_string (buf, printcharfun); |
53 } | 53 } |
54 | 54 |
55 inline static size_t | |
56 aligned_sizeof_opaque (size_t opaque_size) | |
57 { | |
58 return ALIGN_SIZE (offsetof (Lisp_Opaque, data) + opaque_size, | |
59 ALIGNOF (max_align_t)); | |
60 } | |
61 | |
55 static size_t | 62 static size_t |
56 sizeof_opaque (const void *header) | 63 sizeof_opaque (const void *header) |
57 { | 64 { |
58 const Lisp_Opaque *p = (const Lisp_Opaque *) header; | 65 return aligned_sizeof_opaque (((const Lisp_Opaque *) header)->size); |
59 return offsetof (Lisp_Opaque, data) + p->size; | |
60 } | 66 } |
61 | 67 |
62 /* Return an opaque object of size SIZE. | 68 /* Return an opaque object of size SIZE. |
63 If DATA is OPAQUE_CLEAR, the object's data is memset to '\0' bytes. | 69 If DATA is OPAQUE_CLEAR, the object's data is memset to '\0' bytes. |
64 If DATA is OPAQUE_UNINIT, the object's data is uninitialized. | 70 If DATA is OPAQUE_UNINIT, the object's data is uninitialized. |
65 Else the object's data is initialized by copying from DATA. */ | 71 Else the object's data is initialized by copying from DATA. */ |
66 Lisp_Object | 72 Lisp_Object |
67 make_opaque (const void *data, size_t size) | 73 make_opaque (const void *data, size_t size) |
68 { | 74 { |
69 Lisp_Opaque *p = (Lisp_Opaque *) | 75 Lisp_Opaque *p = (Lisp_Opaque *) |
70 alloc_lcrecord (offsetof (Lisp_Opaque, data) + size, &lrecord_opaque); | 76 alloc_lcrecord (aligned_sizeof_opaque (size), &lrecord_opaque); |
71 p->size = size; | 77 p->size = size; |
72 | 78 |
73 if (data == OPAQUE_CLEAR) | 79 if (data == OPAQUE_CLEAR) |
74 memset (p->data, '\0', size); | 80 memset (p->data, '\0', size); |
75 else if (data == OPAQUE_UNINIT) | 81 else if (data == OPAQUE_UNINIT) |