Changeset: 2982240babfa for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2982240babfa
Modified Files:
        sql/storage/store.c
        sql/storage/store_sequence.c
Branch: default
Log Message:

Identation fixes, allocation checks and reuse storage seqchanges


diffs (96 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3941,16 +3941,15 @@ sql_trans_commit(sql_trans *tr)
                                if (c->log && ok == LOG_OK)
                                        ok = c->log(tr, c);
                        }
-                       if (ok == LOG_OK) {
-                               if (!list_empty(store->seqchanges)) {
-                                       sequences_lock(store);
-                                       for(node *n = store->seqchanges->h; n; 
n = n->next) {
-                                               log_store_sequence(store, 
n->data);
-                                       }
-                                       list_destroy(store->seqchanges);
-                                       store->seqchanges = list_create(NULL);
-                                       sequences_unlock(store);
+                       if (ok == LOG_OK && !list_empty(store->seqchanges)) {
+                               sequences_lock(store);
+                               for(node *n = store->seqchanges->h; n; ) {
+                                       node *next = n->next;
+                                       log_store_sequence(store, n->data);
+                                       list_remove_node(store->seqchanges, 
NULL, n);
+                                       n = next;
                                }
+                               sequences_unlock(store);
                        }
                        if (ok == LOG_OK && store->prev_oid != store->obj_id)
                                ok = store->logger_api.log_sequence(store, 
OBJ_SID, store->obj_id);
diff --git a/sql/storage/store_sequence.c b/sql/storage/store_sequence.c
--- a/sql/storage/store_sequence.c
+++ b/sql/storage/store_sequence.c
@@ -56,21 +56,21 @@ sequence_destroy( void *dummy, store_seq
 void
 seq_hash_destroy( sql_hash *h )
 {
-    if (h == NULL || h->sa)
-        return ;
-    for (int i = 0; i < h->size; i++) {
-        sql_hash_e *e = h->buckets[i];
+       if (h == NULL || h->sa)
+               return ;
+       for (int i = 0; i < h->size; i++) {
+               sql_hash_e *e = h->buckets[i];
 
-        while (e) {
-            sql_hash_e *next = e->chain;
+               while (e) {
+                       sql_hash_e *next = e->chain;
 
-            sequence_destroy(NULL, e->value);
-            _DELETE(e);
-            e = next;
-        }
-    }
-    _DELETE(h->buckets);
-    _DELETE(h);
+                       sequence_destroy(NULL, e->value);
+                       _DELETE(e);
+                       e = next;
+               }
+       }
+       _DELETE(h->buckets);
+       _DELETE(h);
 }
 
 static store_sequence *
@@ -78,12 +78,12 @@ sequence_lookup( sql_hash *h, sqlid id)
 {
        sql_hash_e *e = h->buckets[id & (h->size-1)];
        while(e) {
-            sql_hash_e *next = e->chain;
-                       store_sequence *s = e->value;
+               sql_hash_e *next = e->chain;
+               store_sequence *s = e->value;
 
-                       if (s->seqid == id)
-                               return s;
-                       e = next;
+               if (s->seqid == id)
+                       return s;
+               e = next;
        }
        return NULL;
 }
@@ -114,7 +114,10 @@ sequence_create(sqlstore *store, sql_seq
 
        if (!isNew(seq) && store->logger_api.get_sequence(store, seq->base.id, 
&val ))
                s->cur = val;
-       hash_add(store->sequences, seq_hash(s), s);
+       if (!hash_add(store->sequences, seq_hash(s), s)) {
+               _DELETE(s);
+               return NULL;
+       }
        return s;
 }
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to