Linked List

A personal knowledge base

C

#Generate SQL Placeholder String

// Allocate the placeholders string
size_t sizeof_placeholders = 2 * sizeof(uint8_t) * count_of_placeholders;
uint8_t *placeholders = malloc(sizeof_placeholders);
if (placeholders == NULL) {
    // Return an error or raise an exception
}
// Fill it with ?, pairs
memset_pattern8(placeholders, "?,?,?,?,", sizeof_placeholders);
// NUL terminate the string, replacing the unwanted trailing comma
placeholders[sizeof_placeholders - 1] = '\0';
Last modified: 04 Dec 2015