API: Refactor: Register/unregister created/destroyed buffers

- Add the 'handle' field to `buf_T`
- Add declare/implement functions for registering/unregistering/retrieving
  buffers
- Register/unregister buffers when they are created/destroyed.
This commit is contained in:
Thiago de Arruda
2014-05-23 15:49:30 -03:00
parent 7dfc7bc2e1
commit ed99198ff1
4 changed files with 13 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
#include <string.h>
#include "nvim/api/private/handle.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
@@ -538,6 +539,7 @@ void buf_freeall(buf_T *buf, int flags)
*/
static void free_buffer(buf_T *buf)
{
handle_unregister_buffer(buf);
free_buffer_stuff(buf, TRUE);
unref_var_dict(buf->b_vars);
aubuflocal_remove(buf);
@@ -1362,6 +1364,7 @@ buflist_new (
}
if (buf != curbuf || curbuf == NULL) {
buf = xcalloc(1, sizeof(buf_T));
handle_register_buffer(buf);
/* init b: variables */
buf->b_vars = dict_alloc();
init_var_dict(buf->b_vars, &buf->b_bufvar, VAR_SCOPE);