示例#1
0
文件: database.c 项目: perl11/potion
PN potion_callback(Potion *P, PN closure) {
  struct PNCallback *cb = (struct PNCallback *)potion_data_alloc(P, CallbackSize);
  cb->siz = CallbackSize; // To help out GC
  cb->P = P;
  cb->cb = closure;
  return (PN)cb;
}
示例#2
0
文件: gc-test.c 项目: edward/potion
void gc_test_forward(CuTest *T) {
  PN_SIZE count;
  char *fj = "frances johnson.";
  PN ptr = potion_data_alloc(P, 16);
  register unsigned long old = ptr & 0xFFFF;
  memcpy(((struct PNData *)ptr)->data, fj, 16);

  count = potion_mark_stack(P, 1);
  CuAssert(T, "copied location identical to original", (old & 0xFFFF) != ptr);
  CuAssertIntEquals(T, "copied object not still PN_TUSER", ((struct PNData *)ptr)->vt, PN_TUSER);
  CuAssert(T, "copied data not identical to original",
    strncmp(((struct PNData *)ptr)->data, fj, 16) == 0);
}