Version 1 of mem_to_obj

Updated 2004-05-07 02:16:34

GPS: This function is used to create a ByteArray object from a structure/pointer/memory. I use it in combination with obj_to_mem.


 /* REVISION 70 */
 #ifndef _MEM_TO_OBJ_C
 #define _MEM_TO_OBJ_C
 inline Tcl_Obj *
 mem_to_obj ( void *mem, size_t s ) {
  return Tcl_NewByteArrayObj ((unsigned char *)mem, s);
 }
 #endif /* _MEM_TO_OBJ_C */

Example usage:

 GC gc; 
 Tcl_Obj *r;
 /* gc = XCreateGC ... */
 r = mem_to_obj (&gc, sizeof (GC));

See also: obj_to_mem