]> Nishi Git Mirror - dataworks.git/commitdiff
add too many tables error
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sun, 26 May 2024 10:36:54 +0000 (10:36 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sun, 26 May 2024 10:36:54 +0000 (10:36 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@119 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Library/database.c
Library/database_table.c
Library/dw_database.h

index a18cdd7b3a5c802c86bd84412becc0ce504f3735..861c8504c0256fd7e792a4c603ee28981c2cd0ee 100644 (file)
@@ -38,7 +38,7 @@
 
 const char sig[3] = {0x7f, 'D', 'W'};
 
-const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used"};
+const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used", "Too many tables"};
 
 #ifdef M_I86
 #define BUFSIZE 128
index c1815ac70cce1c4856e3a08f4ad0981589c81652..41e1f4c9d54c2c5570b82b5e37c55fcf253f7e6a 100644 (file)
@@ -72,6 +72,7 @@ int dataworks_database_create_table(struct dataworks_db* db, const char* name, c
                int i;
                struct dataworks_db_v1_indexentry index;
                char* buf = malloc(1 + 8 + 1 + 256 + 4096);
+               int cnt = 0;
                for(i = 0; i < 256; i++) {
                        fread(buf, 1, 1 + 8 + 1 + 256 + 4096, db->fp);
                        __dw_buffer_to_db_v1_indexentry(buf, index);
@@ -85,8 +86,14 @@ int dataworks_database_create_table(struct dataworks_db* db, const char* name, c
                                        __dw_unlockfile(db->fp);
                                        return DW_ERR_USED;
                                }
+                               cnt++;
                        }
                }
+               if(cnt == 256) {
+                       free(buf);
+                       __dw_unlockfile(db->fp);
+                       return DW_ERR_TOO_MANY_TABLES;
+               }
                fseek(db->fp, 3 + 10, SEEK_SET);
                for(i = 0; i < 256; i++) {
                        fread(buf, 1, 1 + 8 + 1 + 256 + 4096, db->fp);
index 244d01f13ab4fc5f690184af6b91d678cbc6c427..fbf9ecbb4e8ed0a830e2030e629902ab04e5aa07 100644 (file)
@@ -135,6 +135,13 @@ enum DW_ERRORS {
         *
         */
        DW_ERR_NOT_USED,
+
+       /**
+        * @~english
+        * @brief Too many tables
+        *
+        */
+       DW_ERR_TOO_MANY_TABLES,
 };
 
 /**