Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
sqlite.c File Reference

SQLite handle registry and helper utilities for the Fun VM extension. More...

#include <sqlite3.h>
Include dependency graph for sqlite.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SqlHandle
 Node in a singly-linked list of registered SQLite handles. More...

Typedefs

typedef struct SqlHandle SqlHandle
 Node in a singly-linked list of registered SQLite handles.

Functions

static SqlHandlesql_reg_add (sqlite3 *db)
 Add a sqlite3 handle to the registry.
static SqlHandlesql_reg_get (int id)
 Look up a registered SQLite handle by id.
static void sql_reg_del (int id)
 Remove a SQLite handle entry from the registry.

Variables

static SqlHandleg_sql_handles = NULL
static int g_sql_next_id = 1

Detailed Description

SQLite handle registry and helper utilities for the Fun VM extension.

This module provides a very small registry for SQLite database handles when the project is compiled with FUN_WITH_SQLITE. It assigns small integer identifiers to opened sqlite3 connections and allows retrieval or removal of those entries. The registry itself does not open or close SQLite databases — it only stores pointers provided by the caller.

Thread-safety: This registry is not thread-safe. Callers must ensure external synchronization if used from multiple threads.

Definition in file sqlite.c.

Typedef Documentation

◆ SqlHandle

typedef struct SqlHandle SqlHandle

Node in a singly-linked list of registered SQLite handles.

Function Documentation

◆ sql_reg_add()

SqlHandle * sql_reg_add ( sqlite3 * db)
static

Add a sqlite3 handle to the registry.

The function allocates a new list node, assigns a fresh positive id, and prepends it to the internal registry list.

Parameters
dbValid pointer to an opened sqlite3 connection.
Returns
Pointer to the newly created SqlHandle entry on success; NULL on allocation failure. The returned pointer remains owned by the registry; do not free it directly.
Note
This function does not take ownership of the sqlite3 connection in the sense of closing it; removal from the registry will not call sqlite3_close().

Definition at line 54 of file sqlite.c.

◆ sql_reg_del()

void sql_reg_del ( int id)
static

Remove a SQLite handle entry from the registry.

Deletes the list node associated with the given id.

Parameters
idPositive identifier of the entry to remove.
Note
This function does not close the underlying sqlite3 connection; the caller is responsible for calling sqlite3_close() if appropriate.

Definition at line 85 of file sqlite.c.

◆ sql_reg_get()

SqlHandle * sql_reg_get ( int id)
static

Look up a registered SQLite handle by id.

Parameters
idPositive identifier previously returned by sql_reg_add().
Returns
Pointer to the SqlHandle entry if found; NULL otherwise.

Definition at line 70 of file sqlite.c.

Variable Documentation

◆ g_sql_handles

SqlHandle* g_sql_handles = NULL
static

Global head of the SQLite handle list.

Definition at line 36 of file sqlite.c.

◆ g_sql_next_id

int g_sql_next_id = 1
static

Next positive identifier to assign to a newly added handle.

Definition at line 38 of file sqlite.c.