提交 d5af0586 编写于 作者: H Hongze Cheng

refact

上级 d7848099
......@@ -24,7 +24,8 @@ extern "C" {
extern const SVnodeOptions defaultVnodeOptions;
int vnodeValidateOptions(const SVnodeOptions*);
int vnodeValidateOptions(const SVnodeOptions *);
void vnodeOptionsCopy(SVnodeOptions *pDest, const SVnodeOptions *pSrc);
#ifdef __cplusplus
}
......
......@@ -17,6 +17,8 @@
static SVnode *vnodeNew(const char *path, const SVnodeOptions *pVnodeOptions);
static void vnodeFree(SVnode *pVnode);
static int vnodeOpenImpl(SVnode *pVnode);
static void vnodeCloseImpl(SVnode *pVnode);
SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions) {
SVnode *pVnode = NULL;
......@@ -32,6 +34,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions) {
return NULL;
}
// Create the handle
pVnode = vnodeNew(path, pVnodeOptions);
if (pVnode == NULL) {
// TODO: handle error
......@@ -40,22 +43,52 @@ SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions) {
taosMkDir(path);
// Open the vnode
if (vnodeOpenImpl(pVnode) < 0) {
// TODO: handle error
return NULL;
}
return pVnode;
}
void vnodeClose(SVnode *pVnode) { /* TODO */
void vnodeClose(SVnode *pVnode) {
if (pVnode) {
vnodeCloseImpl(pVnode);
vnodeFree(pVnode);
}
}
void vnodeDestroy(const char *path) { taosRemoveDir(path); }
/* ------------------------ STATIC METHODS ------------------------ */
static SVnode *vnodeNew(const char *path, const SVnodeOptions *pVnodeOptions) {
// TODO
SVnode *pVnode = NULL;
pVnode = (SVnode *)calloc(1, sizeof(*pVnode));
if (pVnode == NULL) {
// TODO
return NULL;
}
pVnode->path = strdup(path);
vnodeOptionsCopy(&(pVnode->options), pVnodeOptions);
return NULL;
}
static void vnodeFree(SVnode *pVnode) {
if (pVnode) {
// TODO
tfree(pVnode->path);
free(pVnode);
}
}
static int vnodeOpenImpl(SVnode *pVnode) {
// TODO
return 0;
}
static void vnodeCloseImpl(SVnode *pVnode) {
// TODO
}
\ No newline at end of file
......@@ -26,4 +26,8 @@ void vnodeOptionsClear(SVnodeOptions *pVnodeOptions) { /* TODO */
int vnodeValidateOptions(const SVnodeOptions *pVnodeOptions) {
// TODO
return 0;
}
void vnodeOptionsCopy(SVnodeOptions *pDest, const SVnodeOptions *pSrc) {
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeOptions));
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册