Small. Fast. Reliable.
Choose any three.

SQLite C Interface

Obtain Aggregate Function Context

void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);

Implementations of aggregate SQL functions use this routine to allocate memory for storing their state.

The first time the sqlite3_aggregate_context(C,N) routine is called for a particular aggregate function, SQLite allocates N of memory, zeroes out that memory, and returns a pointer to the new memory. On second and subsequent calls to sqlite3_aggregate_context() for the same aggregate function instance, the same buffer is returned. Sqlite3_aggregate_context() is normally called once for each invocation of the xStep callback and then one last time when the xFinal callback is invoked. When no rows match an aggregate query, the xStep() callback of the aggregate function implementation is never called and xFinal() is called exactly once. In those cases, sqlite3_aggregate_context() might be called for the first time from within xFinal().

The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is less than or equal to zero or if a memory allocate error % 100% no-repeat } .ne { background: url(../images/ne.gif) 100% 0% no-repeat } .nw { background: url(../images/nw.gif) 0% 0% no-repeat } /* Things for "fancyformat" documents start here. */ .fancy img+p {font-style:italic} .fancy .codeblock i { color: darkblue; } .fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64} .fancy h2 { margin-left: 10px } .fancy h3 { margin-left: 20px } .fancy h4 { margin-left: 30px } .fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444} .fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top} .fancy #toc a { color: darkblue ; text-decoration: none } .fancy .todo { color: #AA3333 ; font-style : italic } .fancy .todo:before { content: 'TODO:' } .fancy p.todo { border: solid #AA3333 1px; padding: 1ex } .fancy img { display:block; } .fancy :link:hover, .fancy :visited:hover { backg