示例#1
0
文件: utils.c 项目: MUME/mudlle
void *debug_xrealloc(const char *file, int line, void *old, int size)
{
  void *newp = debug_realloc(file, line, old, size);

  if (!newp) abort();

  return newp;
}
示例#2
0
static void growingListAdd(GrowingList* pList, size_t objSize) {
    if (pList->count == pList->alloc) {
        size_t oldsize = pList->alloc * objSize;
        pList->alloc += PAGESIZE / objSize;
        size_t size = pList->alloc * objSize;
        pList->data = debug_realloc(pList->data, size, oldsize);
    }
    pList->count++;
}
示例#3
0
void *shell_reallocdebug(const char *file, unsigned int line, void *ptr, unsigned long size)
{
  void *newptr;

  if(ptr == NULL)
    return shell_allocdebug(file, line, size);

  newptr = debug_realloc(file, line, ptr, size);

  /* exit if failed */
  if(newptr == NULL) {
    shell_error("realloc");
    exit(1);
  }

  /* return pointer otherwise */
  return newptr;
}
示例#4
0
void *
_Realloc(
	char	*file,
	int	line,
	void	*p,
	size_t	s
)
{
	if (p == NULL)
		p = debug_malloc(file, line, s);
	else
		p = debug_realloc(file, line, p, s);
	if (p == NULL) {
		md_perror("");
		md_exit(NULL, 1);
	}
	return (p);
}