In computer science, pointer swizzling is the conversion of references based on name or position into direct pointer references (memory addresses). It is typically performed during deserialization or loading of a relocatable object from a disk file, such as an executable file or pointer-based data structure. The reverse operation, replacing memory pointers with position-independent symbols or positions, is sometimes referred to as unswizzling, and is performed during serialization (saving). Example It is easy to create a linked list data structure using elements like this: struct node { int data; struct node *next; }; But saving the list to a file and then reloading it will (on most operating systems) break every link and render the list useless because the nodes will almost never be loaded into the same memory locations. One way to usefully save and retrieve the list is to assign a unique id number to each node and then unswizzle the pointers by turning them into a field indicating the id number of the next node: struct node_saved { int data; int id_number; int id_number_of_next_node; }; Records like these can be saved to a file in any order and reloaded without breaking the list. Other options include saving the file offset of the next node or a number indicating its position in the sequence of saved records, or simply saving the nodes in-order to the file. After loading such a list, finding a node based on its number is cumbersome and inefficient (serial search). Traversing the list was very fast with the original "next" pointers. To convert the list back to its original form, or swizzle the pointers, requires finding the address of each node and turning the id_number_of_next_node fields back into direct pointers to the right node. Methods of unswizzling There are a potentially unlimited number of forms into which a pointer can be unswizzled, but some of the most popular include: The offset of the pointed-to object in the file The index of the pointed-to object in some sequence of records A unique identifier possessed by the pointed-to object, such as a person's Social Security number; in databases, all pointers are unswizzled in this manner (see Foreign key). Methods of swizzling Swizzling in the general case can be complicated. The reference graph of pointers might contain an arbitrary number of cycles; this complicates maintaining a mapping from the old unswizzled values to the new addresses. Associative