Source talk:NetHack 3.4.3/include/obj.h
An object is normally allocated to have extra space after the end of the struct. Using ONAME(thing) retrieves some text from this extra space. I think that ONAME probably contains the name left with the #name command (such as "cursed" or "REAL", if you ever have a "yellow potion named cursed" or an "Amulet of Yendor named REAL"), however I would have to examine do_name.c more carefully to learn the details. I find this approach difficult to understand.
When you give a longer #name to an object, you would have to reallocate it, thus possibly making invalid any pointers to that object. It appears that in do_name.c, do_oname calls oname which calls realloc_obj to do this. This process feels all unnecessary to me because I would have put a char* in the struct and allocated the name string separately. --Kernigh 20:07, 19 June 2006 (UTC)