2
0
Эх сурвалжийг харах

- the root db structure renamed to avoid conflicts with variables in modules
- db_fld_copy must copy also the terminating element in the array

Jan Janak 18 жил өмнө
parent
commit
f7a39e3951
2 өөрчлөгдсөн 3 нэмэгдсэн , 2 устгасан
  1. 2 2
      db/db_ctx.c
  2. 1 0
      db/db_fld.c

+ 2 - 2
db/db_ctx.c

@@ -87,7 +87,7 @@ db_ctx_t* db_ctx(const char* id)
 	/* Insert the newly created context into the linked list
 	 * of all existing contexts
 	 */
-	DBLIST_INSERT_HEAD(&db, newp);
+	DBLIST_INSERT_HEAD(&db_root, newp);
     return newp;
 
  error:
@@ -114,7 +114,7 @@ void db_ctx_free(db_ctx_t* ctx)
 	/* Remove the context from the linked list of
 	 * all contexts
 	 */
-	DBLIST_REMOVE(&db, ctx);
+	DBLIST_REMOVE(&db_root, ctx);
 
 	/* Disconnect all connections */
 	db_disconnect(ctx);

+ 1 - 0
db/db_fld.c

@@ -89,6 +89,7 @@ db_fld_t* db_fld_copy(db_fld_t* fld)
 	db_fld_t* newp;
 
 	for(n = 0; fld[n].name; n++);
+	n++; /* We need to copy the terminating element too */
 
 	newp = (db_fld_t*)pkg_malloc(sizeof(db_fld_t) * n);
 	if (newp == NULL) {