Beispiel #1
0
static void
cframe_clear(PyCFrameObject *cf)
{
#define ZAP(x) \
	if (x != NULL) { \
		PyObject *_hold = (PyObject *) x; \
		x = NULL; \
		Py_XDECREF(_hold); \
	}
	ZAP(cf->f_back);
	ZAP(cf->ob1);
	ZAP(cf->ob2);
	ZAP(cf->ob3);
#undef ZAP
}
Beispiel #2
0
static void
bomb_clear(PyBombObject *bomb)
{
#define ZAP(x) \
	if (x != NULL) { \
		PyObject *_hold = (PyObject *) x; \
		x = NULL; \
		Py_XDECREF(_hold); \
	}

	ZAP(bomb->curexc_type);
	ZAP(bomb->curexc_value);
	ZAP(bomb->curexc_traceback);

#undef ZAP
}
static void m_deepin_lunar_dealloc(DeepinLunarObject *self) 
{
    PyObject_GC_UnTrack(self);
    Py_TRASHCAN_SAFE_BEGIN(self)

    ZAP(self->dict);
    m_delete(self);

    PyObject_GC_Del(self);
    Py_TRASHCAN_SAFE_END(self)
}
Beispiel #4
0
/* Open a directory iterator.
 * This function takes a directory name that begins with a drive letter.
 * Example: "a:/mystuff/musicdir" */
static void *
e_hfat_opendir (const char *name)
{
  unsigned int len;
  struct hfat_iterator *iter;

  len = strlen (name);

  /* We require a drive letter, colon, and leading slash */
  if (name[0] == '\0' || name[1] != ':' || name[2] != '/' || len < 3)
    return NULL;

  /* Don't count any trailing '/' in the length */
  while (name[len - 1] == '/')
    len--;

  /* If the directory name is longer than we expect, fail */
  if (len > HFAT_MAX_PATH_UTF8)
    return NULL;

  /* Grab an iterator from iterator pool */
  iter = get_free_iterator ();

  if (!iter)
  {
    ZAP ("No iterators available\n");
    return NULL;
  }

  /* Initialize the iterator index to 0 so that we know that we just
     created the iterator */
  iter->index = 0;

  /* Initialize the dirname field of the iterator. We need this in readdir
     to pass to f_findfirst() and f_findnext() */
  memcpy (iter->dirname, name, len);

  /* HFAT requires this to find all the files in the directory */
  fs_strlcpy (iter->dirname + len, "/*.*", sizeof (iter->dirname) - len);

  /* The root directory in FAT does not contain '.' and '..'.  We need
     to fake them with these two special iterator states.  Look for
     any root directory name ("?:/") and start with these fake
     entries. */
  if (name[0] != 0 && name[1] == ':' && name[2] == '/' && name[3] == 0)
    iter->state = ITER_STATE_DOT;
  else
    iter->state = ITER_STATE_NORMAL;

  return iter;
}
static PyObject *m_deepin_lunar_clear(DeepinLunarObject *self) 
{
    ZAP(self->dict);
    return 0;
}