/**
* ntdb_open - open a database file
- * @name: the file name (can be NULL if flags contains NTDB_INTERNAL)
+ * @name: the file name (or database name if flags contains NTDB_INTERNAL)
* @ntdb_flags: options for this database
* @open_flags: flags argument for ntdb's open() call.
* @mode: mode argument for ntdb's open() call.
* ntdb_name - get the name of a ntdb
* @ntdb: the ntdb context returned from ntdb_open()
*
- * This returns a copy of the name string, made at ntdb_open() time. If that
- * argument was NULL (possible for a NTDB_INTERNAL db) this will return NULL.
+ * This returns a copy of the name string, made at ntdb_open() time.
*
* This is mostly useful for logging.
*/
enum NTDB_ERROR ecode;
int openlock;
- ntdb = malloc(sizeof(*ntdb) + (name ? strlen(name) + 1 : 0));
+ ntdb = malloc(sizeof(*ntdb) + strlen(name) + 1);
if (!ntdb) {
/* Can't log this */
errno = ENOMEM;
return NULL;
}
/* Set name immediately for logging functions. */
- if (name) {
- ntdb->name = strcpy((char *)(ntdb + 1), name);
- } else {
- ntdb->name = NULL;
- }
+ ntdb->name = strcpy((char *)(ntdb + 1), name);
ntdb->flags = ntdb_flags;
ntdb->log_fn = NULL;
ntdb->open_flags = open_flags;
/* Fill with some weird pattern. */
memset(mem, 0x99, off);
/* Now populate our header, cribbing from a real NTDB header. */
- ntdb = ntdb_open(NULL, NTDB_INTERNAL, O_RDWR, 0, attr);
+ ntdb = ntdb_open("layout", NTDB_INTERNAL, O_RDWR, 0, attr);
memcpy(mem, ntdb->file->map_ptr, sizeof(struct ntdb_header));
/* Mug the ntdb we have to make it use this. */