fork download
  1.  
  2.  
  3. struct Connection *db_open(const char *filename, char row, int nrows,
  4. int strsize)
  5. {
  6. struct Connection *con;
  7. char *buf;
  8. int i;
  9.  
  10. if (!(con = malloc(sizeof *con))
  11. || !(con->db = malloc(sizeof *con->db))
  12. || !(con->db->rows = malloc(sizeof *con->db->rows * nrows))
  13. || !(buf = malloc(strsize * nrows * 2)))
  14. die("memory error");
  15. for (i = 0; i < nrows; i++) {
  16. conn->db->rows[i].name = buf;
  17. conn->db->rows[i].email = buf + strsize;
  18. buf += strsize * 2;
  19. }
  20. return con;
  21. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty