#include <malloc.h>
#include <errno.h>
#include "xgetcwd.h"

void *myrealloc(void *PTR, size_t SIZE, const void *CALLER)
{
  errno = ENOMEM;
  return 0;
}

main()
{
  char *acwd;

  puts("This shoould return the cwd:");

  acwd = xgetcwd();
  if (acwd)
    {
      printf("   %s\n",acwd);
    }
  else
    {
      printf("   error: %s\n",strerror(errno));
    }

  printf("strlen: %d\n\n",strlen(acwd));

  free(acwd);

  __realloc_hook = myrealloc;

  puts("This should return a no memory error: ");

  acwd = xgetcwd();
  if (acwd)
    {
      printf("   %s\n",acwd);
    }
  else
    {
      printf("   error: %s\n",strerror(errno));
    }

  return 0;
}


