/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------* Project: MEM library File: list.h Programmers: Takano Makoto Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef MEM_LIST_H__ #define MEM_LIST_H__ #ifdef __cplusplus extern "C" { #endif #include #include /*---------------------------------------------------------------------------* Name: MEMLink Description: Node structure for a doubly linked list. This structure is stored as a member of the structure to link. *---------------------------------------------------------------------------*/ typedef struct { void* prevObject; // Pointer to the previous linked object. void* nextObject; // Pointer to the next linked object. } MEMLink; /*---------------------------------------------------------------------------* Name: MEMList Description: Doubly linked list structure. *---------------------------------------------------------------------------*/ typedef struct { void* headObject; // Pointer to the object linked to the top of the list. void* tailObject; // Pointer to the object linked to the end of the list. u16 numObjects; // Number of objects linked in the list. u16 offset; // Offset for the NNSFndLink type structure member. } MEMList; /*---------------------------------------------------------------------------* Name: MEM_INIT_LIST Description: Macro for initializing list structures. Actual initialization is performed by the NNS_FndInitList function. Performed by the MEMInitList function. This macro finds the offset using the offsetof macro based on the name of the specified structure and the Link type member variable name, and then passes that offset to the NNSFndInitList function. Arguments: list: Pointer to the link structure. structName: Structure name of the object to link in the list. linkName: The Link type member variable name used to link this object. Returns: None. *---------------------------------------------------------------------------*/ #define MEM_INIT_LIST(list, structName, linkName) \ MEMInitList(list, offsetof(structName, linkName)) /*---------------------------------------------------------------------------* Function Prototypes *---------------------------------------------------------------------------*/ void MEMInitList( MEMList* list, u16 offset); void MEMAppendListObject( MEMList* list, void* object); void MEMPrependListObject( MEMList* list, void* object); void MEMInsertListObject( MEMList* list, void* target, void* object); void MEMRemoveListObject( MEMList* list, void* object); void* MEMGetNextListObject( MEMList* list, void* object); void* MEMGetPrevListObject( MEMList* list, void* object); void* MEMGetNthListObject( MEMList* list, u16 index); #ifdef __cplusplus } /* extern "C" */ #endif /* MEM_LIST_H__ */ #endif