src/passwordstore/passwordstore.c
// Writes password record to db, starting from offset *db_len.
// Also, updates *db_len so that it points to the offset after the end
// of the written record.
Writes password record to db, starting from offset *db_len.
Also, updates *db_len so that it points to the offset after the end
of the written record.
Writes password record to db starting from offset * db_len . Also updates * db_len so that it points to the offset after the end of the written record .
static void writeDbRecord(char *db, size_t *db_len,
        struct PasswordDbRecord *rec)
{
    if (rec->password == NULL || rec->password_len == 0) {
        return;
    }
    *((size_t *)(db + *db_len)) = rec->id_len;
    *db_len += sizeof(size_t);
    *((size_t *)(db + *db_len)) = rec->password_len;
    *db_len += sizeof(size_t);
    memcpy(db + *db_len, rec->id, rec->id_len);
    *db_len += rec->id_len;
    memcpy(db + *db_len, rec->password, rec->password_len);
    *db_len += rec->password_len;
}
static void writeDbRecord ( char * db , size_t * db_len , struct PasswordDbRecord * rec ) { if ( rec -> password == NULL || rec -> password_len == 0 ) { return ; } * ( ( size_t * ) ( db + * db_len ) ) = rec -> id_len ; * db_len += sizeof ( size_t ) ; * ( ( size_t * ) ( db + * db_len ) ) = rec -> password_len ; * db_len += sizeof ( size_t ) ; memcpy ( db + * db_len , rec -> id , rec -> id_len ) ; * db_len += rec -> id_len ; memcpy ( db + * db_len , rec -> password , rec -> password_len ) ; * db_len += rec -> password_len ; }
Writes password record to db, starting from offset *db_len.
Writes password record to db starting from offset * db_len .
// Don't write empty passwords. // Write len of ID // Write len of password // Copy ID // Copy password