コード例 #1
0
ファイル: memory.c プロジェクト: navbor/neovim
char * xstrdup(const char *str)
{
  char *ret = strdup(str);

  if (!ret) {
    try_to_free_memory();
    ret = strdup(str);
    if (!ret) {
      OUT_STR("Vim: Error: Out of memory.\n");
      preserve_exit();
    }
  }

  return ret;
}
コード例 #2
0
ファイル: memory.c プロジェクト: kapysaxena/neovim
void *try_malloc(size_t size)
{
  void *ret = malloc(size);

  if (!ret && !size) {
    ret = malloc(1);
  }
  if (!ret) {
    try_to_free_memory();
    ret = malloc(size);
    if (!ret && !size) {
      ret = malloc(1);
    }
  }
  return ret;
}
コード例 #3
0
ファイル: memory.c プロジェクト: kapysaxena/neovim
void *xrealloc(void *ptr, size_t size)
{
  void *ret = realloc(ptr, size);

  if (!ret && !size)
    ret = realloc(ptr, 1);

  if (!ret) {
    try_to_free_memory();
    ret = realloc(ptr, size);
    if (!ret && !size)
      ret = realloc(ptr, 1);
    if (!ret) {
      OUT_STR("Vim: Error: Out of memory.\n");
      preserve_exit();
    }
  }

  return ret;
}
コード例 #4
0
ファイル: memory.c プロジェクト: kapysaxena/neovim
void *xcalloc(size_t count, size_t size)
{
  void *ret = calloc(count, size);

  if (!ret && (!count || !size))
    ret = calloc(1, 1);

  if (!ret) {
    try_to_free_memory();
    ret = calloc(count, size);
    if (!ret && (!count || !size))
      ret = calloc(1, 1);
    if (!ret) {
      OUT_STR("Vim: Error: Out of memory.\n");
      preserve_exit();
    }
  }

  return ret;
}