OSDN Git Service

svn rev.329より移動。
[chnosproject/CHNOSProject.git] / CHNOSProject / chnos / tolset_chn_000 / chnos_010 / chnos / struct.c
diff --git a/CHNOSProject/chnos/tolset_chn_000/chnos_010/chnos/struct.c b/CHNOSProject/chnos/tolset_chn_000/chnos_010/chnos/struct.c
new file mode 100644 (file)
index 0000000..c88090b
--- /dev/null
@@ -0,0 +1,65 @@
+\r
+/*\83V\83X\83e\83\80\8d\\91¢\91Ì\8b¤\92Ê\8aÇ\97\9d\83\8b\81[\83`\83\93*/\r
+\r
+#include "core.h"\r
+\r
+System_CommonStruct *System_CommonStruct_Allocate(uint structid)\r
+{\r
+       uint strsize;\r
+       System_CommonStruct *str;\r
+\r
+       strsize = 0;\r
+       switch(structid){\r
+               case SYSTEM_STRUCTID_SHEET:\r
+                       strsize = sizeof(UI_Sheet);\r
+                       break;\r
+               case SYSTEM_STRUCTID_FIFO32:\r
+                       strsize = sizeof(DATA_FIFO32);\r
+                       break;\r
+               case SYSTEM_STRUCTID_TEXTBOX:\r
+                       strsize = sizeof(UI_TextBox);\r
+                       break;\r
+               case SYSTEM_STRUCTID_CONSOLE:\r
+                       strsize = sizeof(UI_Console);\r
+                       break;\r
+               case SYSTEM_STRUCTID_FLOPPYDISK:\r
+                       strsize = sizeof(IO_FloppyDisk);\r
+                       break;\r
+               case SYSTEM_STRUCTID_FILE:\r
+                       strsize = sizeof(IO_File);\r
+                       break;\r
+               default:\r
+                       #ifdef CHNOSPROJECT_DEBUG_COMMON_STRUCT\r
+                               debug("System_CommonStruct_Allocate:Unknown Struct.\n");\r
+                       #endif\r
+                       return Null;\r
+       }\r
+\r
+       str = System_Memory_Allocate(strsize);\r
+       str->structid = structid;\r
+       str->structsize = strsize;\r
+\r
+       return str;\r
+}\r
+\r
+uint System_CommonStruct_Free(System_CommonStruct *str)\r
+{\r
+       switch(str->structid){\r
+               case SYSTEM_STRUCTID_SHEET:\r
+               case SYSTEM_STRUCTID_FIFO32:\r
+               case SYSTEM_STRUCTID_TEXTBOX:\r
+               case SYSTEM_STRUCTID_CONSOLE:\r
+               case SYSTEM_STRUCTID_FLOPPYDISK:\r
+               case SYSTEM_STRUCTID_FILE:\r
+                       break;\r
+               default:\r
+                       #ifdef CHNOSPROJECT_DEBUG_COMMON_STRUCT\r
+                               debug("System_CommonStruct_Free:Unknown Struct.\n");\r
+                       #endif\r
+               return 1;\r
+       }\r
+       str->structid = SYSTEM_STRUCTID_UNDEFINED;\r
+       System_Memory_Free(str, str->structsize);\r
+       return 0;\r
+}\r
+\r