コード例 #1
0
ファイル: name_move_alias.c プロジェクト: syntheticpp/dirfile
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  const char *data = "dirfile/data";
  const char *zata = "dirfile/zata";
  const char *format_data = "cata RAW UINT8 8\n/ALIAS data cata\n"
    "eata RAW UINT8 8\n";
  unsigned char data_data[256];
  int fd, ret, error, unlink_data, unlink_zata, r = 0;
  const char **fl;
  char *field_list[4];
  DIRFILE *D;

  rmdirfile();
  mkdir(filedir, 0777);

  for (fd = 0; fd < 256; ++fd)
    data_data[fd] = (unsigned char)fd;

  fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
  write(fd, format_data, strlen(format_data));
  close(fd);

  fd = open(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666);
  write(fd, data_data, 256);
  close(fd);

  D = gd_open(filedir, GD_RDWR | GD_VERBOSE);
  ret = gd_rename(D, "data", "zata", GD_REN_DATA);
  error = gd_error(D);
  fl = gd_field_list(D);

  field_list[0] = strdup(fl[0]);
  field_list[1] = strdup(fl[1]);
  field_list[2] = strdup(fl[2]);
  field_list[3] = strdup(fl[3]);

  gd_close(D);

  unlink_data = unlink(data);
  unlink_zata = unlink(zata);
  unlink(format);
  rmdir(filedir);

  CHECKI(error, 0);
  CHECKI(ret, 0);
  CHECKS(field_list[0], "INDEX");
  CHECKS(field_list[1], "cata");
  CHECKS(field_list[2], "eata");
  CHECKS(field_list[3], "zata");
  CHECKI(unlink_data, 0);
  CHECKI(unlink_zata, -1);
  free(field_list[0]);
  free(field_list[1]);
  free(field_list[2]);
  free(field_list[3]);

  return r;
}
コード例 #2
0
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  const char *format_data = 
    "early RAW UINT8 c\n"
    "late RAW UINT8 c\n"
    "/ALIAS b c\n"
    "e CONST UINT8 2\n"
    "/ALIAS c e\n";
  int fd, e1, e2, e3, e4, r = 0;
  char *s1, *s2, *s3;
  DIRFILE *D;
  gd_entry_t E;

  rmdirfile();
  mkdir(filedir, 0777);

  fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
  write(fd, format_data, strlen(format_data));
  close(fd);

  D = gd_open(filedir, GD_RDWR);
  gd_validate(D, "early");
  gd_rename(D, "c", "d", GD_REN_UPDB);
  e1 = gd_error(D);
  gd_spf(D, "early");
  e2 = gd_error(D);
  gd_spf(D, "late");
  e3 = gd_error(D);

  gd_entry(D, "early", &E);
  s1 = E.scalar[0];
  E.scalar[0] = NULL;
  gd_free_entry_strings(&E);

  gd_entry(D, "late", &E);
  s2 = E.scalar[0];
  E.scalar[0] = NULL;
  gd_free_entry_strings(&E);

  gd_entry(D, "b", &E);
  e4 = gd_error(D);
  s3 = strdup(gd_alias_target(D, "b"));

  gd_discard(D);

  unlink(format);
  rmdir(filedir);

  CHECKI(e1,0);
  CHECKI(e2,0);
  CHECKI(e3,0);
  CHECKI(e4,0);
  CHECKS(s1, "d");
  CHECKS(s2, "d");
  CHECKS(s3, "d");

  return r;
}
コード例 #3
0
ファイル: madd_linterp.c プロジェクト: syntheticpp/dirfile
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  int error, ge_error, r = 0;
  gd_entry_t e;
  DIRFILE *D;

  rmdirfile();
  D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
  gd_add_phase(D, "new", "in", 3, 0);
  gd_madd_linterp(D, "new", "meta", "in", "table");
  error = gd_error(D);

  /* check */
  gd_entry(D, "new/meta", &e);
  ge_error = gd_error(D);
  CHECKI(ge_error, 0);
  if (!r) {
    CHECKI(e.field_type, GD_LINTERP_ENTRY);
    CHECKS(e.in_fields[0], "in");
    CHECKS(e.EN(linterp,table), "table");
    CHECKI(e.fragment_index, 0);
    gd_free_entry_strings(&e);
  }

  gd_close(D);

  unlink(format);
  rmdir(filedir);

  CHECKI(error, GD_E_OK); 
  return r;
}
コード例 #4
0
ファイル: parse.c プロジェクト: martinjrobins/smoldyn_fork
/* Parse_Start. */
ParseFilePtr Parse_Start(const char *fileroot,const char *filename,char *erstr) {
	ParseFilePtr pfp;
	char string[STRCHAR];

	pfp=Parse_AllocFilePtr(fileroot,filename);
	CHECKS(pfp,"Unable to allocate memory for reading configuration file");
	pfp->fptr=fopen(pfp->fname,"r");
	if(!pfp->fptr) {
		sprintf(string,"File '%s' not found\n",pfp->fname);
		Parse_FreeFilePtr(pfp);
		CHECKS(0,"%s",string); }
	return pfp;

 failure:
	return NULL; }
コード例 #5
0
ファイル: arenavm.c プロジェクト: BarAgent/mps-temporary
static Bool VMArenaCheck(VMArena vmArena)
{
  Arena arena;
  VMChunk primary;

  CHECKS(VMArena, vmArena);
  arena = VMArena2Arena(vmArena);
  CHECKD(Arena, arena);
  /* spare pages are committed, so must be less spare than committed. */
  CHECKL(vmArena->spareSize <= arena->committed);

  CHECKL(vmArena->extendBy > 0);
  CHECKL(vmArena->extendMin <= vmArena->extendBy);

  if (arena->primary != NULL) {
    primary = Chunk2VMChunk(arena->primary);
    CHECKD(VMChunk, primary);
    /* We could iterate over all chunks accumulating an accurate */
    /* count of committed, but we don't have all day. */
    CHECKL(VMMapped(primary->vm) <= arena->committed);
  }
  
  CHECKD_NOSIG(Ring, &vmArena->spareRing);

  /* FIXME: Can't check VMParams */

  return TRUE;
}
コード例 #6
0
ファイル: lockix.c プロジェクト: alisheikh/hornet
Bool LockCheck(Lock lock)
{
  CHECKS(Lock, lock);
  /* While claims can't be very large, I don't dare to put a limit on it. */
  /* There's no way to test the mutex, or check if it's held by somebody. */
  return TRUE;
}
コード例 #7
0
ファイル: prmcw3.c プロジェクト: Ravenbrook/mps
Bool MutatorContextCheck(MutatorContext context)
{
  CHECKS(MutatorContext, context);
  CHECKL(NONNEGATIVE(context->var));
  CHECKL(context->var < MutatorContextLIMIT);
  return TRUE;
}
コード例 #8
0
ファイル: arg.c プロジェクト: datafueled/memory-pool-system
Bool KeyCheck(Key key)
{
  CHECKS(Key, key);
  CHECKL(key->name != NULL);
  CHECKL(FUNCHECK(key->check));
  return TRUE;
}
コード例 #9
0
ファイル: buffer.c プロジェクト: Ravenbrook/mps
Bool SegBufCheck(SegBuf segbuf)
{
  Buffer buffer;
  CHECKS(SegBuf, segbuf);
  buffer = MustBeA(Buffer, segbuf);
  CHECKD(Buffer, buffer);
  CHECKL(RankSetCheck(segbuf->rankSet));

  if (buffer->mode & BufferModeTRANSITION) {
    /* nothing to check */
  } else if ((buffer->mode & BufferModeATTACHED) == 0) {
    CHECKL(segbuf->seg == NULL);
  } else {
    /* The buffer is attached to a segment. */
    CHECKL(segbuf->seg != NULL);
    CHECKD(Seg, segbuf->seg);
    /* To avoid recursive checking, leave it to SegCheck to make */
    /* sure the buffer and segment fields tally. */
   
    if (buffer->mode & BufferModeFLIPPED) {
      /* Only buffers that allocate pointers get flipped. */
      CHECKL(segbuf->rankSet != RankSetEMPTY);
    }
  }

  return TRUE;
}
コード例 #10
0
ファイル: segsmss.c プロジェクト: Ravenbrook/mps
ATTRIBUTE_UNUSED
static Bool AMSTCheck(AMST amst)
{
  CHECKS(AMST, amst);
  CHECKD_NOSIG(AMS, AMST2AMS(amst)); /* <design/check#.hidden-type> */
  return TRUE;
}
コード例 #11
0
ファイル: walk.c プロジェクト: BarAgent/mps-temporary
static Bool FormattedObjectsStepClosureCheck(FormattedObjectsStepClosure c)
{
  CHECKS(FormattedObjectsStepClosure, c);
  CHECKL(FUNCHECK(c->f));
  /* p and s fields are arbitrary closures which cannot be checked */
  return TRUE;
}
コード例 #12
0
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  const char *format_data = "/ALIAS alias target\n/ALIAS target next\n";
  int fd, e, r = 0;
  DIRFILE *D;
  const char *t;

  rmdirfile();
  mkdir(filedir, 0777);

  fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
  write(fd, format_data, strlen(format_data));
  close(fd);

  D = gd_open(filedir, GD_RDONLY | GD_VERBOSE);

  t = gd_alias_target(D, "alias");
  CHECKS(t, "target");
  e = gd_error(D);

  CHECKI(e, GD_E_OK);

  gd_close(D);
  unlink(format);
  rmdir(filedir);

  return r;
}
コード例 #13
0
ファイル: add_sbit.c プロジェクト: syntheticpp/dirfile
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  int error, r = 0;
  gd_entry_t e;
  DIRFILE *D;

  rmdirfile();
  D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
  gd_add_sbit(D, "new", "input", 1, 1, 0);
  error = gd_error(D);

  /* check */
  gd_entry(D, "new", &e);
  if (gd_error(D))
    r = 1;
  else {
    CHECKI(e.field_type, GD_SBIT_ENTRY);
    CHECKS(e.in_fields[0], "input");
    CHECKI(e.fragment_index, 0);
    CHECKI(e.EN(bit,bitnum), 1);
    CHECKI(e.EN(bit,numbits), 1);
    gd_free_entry_strings(&e);
  }

  gd_close(D);

  unlink(format);
  rmdir(filedir);

  CHECKI(error, GD_E_OK);
  
  return r;
}
コード例 #14
0
ファイル: poolmv2.c プロジェクト: Ravenbrook/mps
ATTRIBUTE_UNUSED
static Bool MVTCheck(MVT mvt)
{
  CHECKS(MVT, mvt);
  CHECKC(MVTPool, mvt);
  CHECKD(Pool, MVTPool(mvt));
  CHECKC(MVTPool, mvt);
  CHECKD(CBS, &mvt->cbsStruct);
  CHECKD(ABQ, &mvt->abqStruct);
  CHECKD(Freelist, &mvt->flStruct);
  CHECKD(Failover, &mvt->foStruct);
  CHECKL(mvt->reuseSize >= 2 * mvt->fillSize);
  CHECKL(mvt->fillSize >= mvt->maxSize);
  CHECKL(mvt->maxSize >= mvt->meanSize);
  CHECKL(mvt->meanSize >= mvt->minSize);
  CHECKL(mvt->minSize > 0);
  CHECKL(mvt->fragLimit <= 100);
  CHECKL(mvt->availLimit == mvt->size * mvt->fragLimit / 100);
  CHECKL(BoolCheck(mvt->abqOverflow));
  CHECKL(BoolCheck(mvt->splinter));
  if (mvt->splinter) {
    CHECKL(AddrOffset(mvt->splinterBase, mvt->splinterLimit) >=
           mvt->minSize);
    CHECKL(mvt->splinterBase < mvt->splinterLimit);
  }
  CHECKL(mvt->size == mvt->allocated + mvt->available +
         mvt->unavailable);
  /* --- could check that sum of segment sizes == mvt->size */
  /* --- check meters? */

  return TRUE;
}
コード例 #15
0
ファイル: add_string.c プロジェクト: syntheticpp/dirfile
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  int error, r = 0;
  gd_entry_t e;
  char val[1000];
  DIRFILE *D;

  rmdirfile();
  D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
  gd_add_string(D, "data", "A string.", 0);
  error = gd_error(D);

  /* check */
  gd_entry(D, "data", &e);
  if (gd_error(D))
    r = 1;
  else {
    CHECKI(e.field_type, GD_STRING_ENTRY);
    CHECKI(e.fragment_index, 0);
    gd_get_string(D, "data", 1000, val);
    CHECKS(val, "A string.");
    gd_free_entry_strings(&e);
  }

  gd_close(D);

  unlink(format);
  rmdir(filedir);

  CHECKI(error, GD_E_OK);

  return r;
}
コード例 #16
0
Bool ThreadCheck(Thread thread)
{
    CHECKS(Thread, thread);
    CHECKU(Arena, thread->arena);
    CHECKL(thread->serial < thread->arena->threadSerial);
    CHECKL(RingCheck(&thread->arenaRing));
    return TRUE;
}
コード例 #17
0
ファイル: freelist.c プロジェクト: alisheikh/hornet
Bool FreelistCheck(Freelist fl)
{
  CHECKS(Freelist, fl);
  /* See <design/freelist/#impl.grain.align> */
  CHECKL(AlignIsAligned(fl->alignment, freelistMinimumAlignment));
  CHECKL((fl->list == NULL) == (fl->listSize == 0));
  return TRUE;
}
コード例 #18
0
ファイル: segsmss.c プロジェクト: Ravenbrook/mps
ATTRIBUTE_UNUSED
static Bool AMSTSegCheck(AMSTSeg amstseg)
{
  CHECKS(AMSTSeg, amstseg);
  CHECKD_NOSIG(AMSSeg, &amstseg->amsSegStruct); /* <design/check#.hidden-type> */
  /* don't bother to do other checks - this is a stress test */
  return TRUE;
}
コード例 #19
0
ファイル: pool.c プロジェクト: bhanug/mps
Bool PoolClassCheck(PoolClass klass)
{
  CHECKD(InstClass, &klass->protocol);
  CHECKL(klass->size >= sizeof(PoolStruct));
  CHECKL(AttrCheck(klass->attr));
  CHECKL(!(klass->attr & AttrMOVINGGC) || (klass->attr & AttrGC));
  CHECKL(FUNCHECK(klass->varargs));
  CHECKL(FUNCHECK(klass->init));
  CHECKL(FUNCHECK(klass->finish));
  CHECKL(FUNCHECK(klass->alloc));
  CHECKL(FUNCHECK(klass->free));
  CHECKL(FUNCHECK(klass->bufferFill));
  CHECKL(FUNCHECK(klass->bufferEmpty));
  CHECKL(FUNCHECK(klass->access));
  CHECKL(FUNCHECK(klass->whiten));
  CHECKL(FUNCHECK(klass->grey));
  CHECKL(FUNCHECK(klass->blacken));
  CHECKL(FUNCHECK(klass->scan));
  CHECKL(FUNCHECK(klass->fix));
  CHECKL(FUNCHECK(klass->fixEmergency));
  CHECKL(FUNCHECK(klass->reclaim));
  CHECKL(FUNCHECK(klass->traceEnd));
  CHECKL(FUNCHECK(klass->rampBegin));
  CHECKL(FUNCHECK(klass->rampEnd));
  CHECKL(FUNCHECK(klass->framePush));
  CHECKL(FUNCHECK(klass->framePop));
  CHECKL(FUNCHECK(klass->addrObject));
  CHECKL(FUNCHECK(klass->walk));
  CHECKL(FUNCHECK(klass->freewalk));
  CHECKL(FUNCHECK(klass->bufferClass));
  CHECKL(FUNCHECK(klass->describe));
  CHECKL(FUNCHECK(klass->debugMixin));
  CHECKL(FUNCHECK(klass->totalSize));
  CHECKL(FUNCHECK(klass->freeSize));

  /* Check that pool classes overide sets of related methods. */
  CHECKL((klass->init == PoolAbsInit) == (klass->finish == PoolAbsFinish));
  CHECKL((klass->bufferFill == PoolNoBufferFill) ==
         (klass->bufferEmpty == PoolNoBufferEmpty));
  CHECKL((klass->framePush == PoolNoFramePush) ==
         (klass->framePop == PoolNoFramePop));
  CHECKL((klass->rampBegin == PoolNoRampBegin) ==
         (klass->rampEnd == PoolNoRampEnd));

  /* Check that pool classes that set attributes also override the
     methods they imply. */
  /* .check.ams.walk: Can't enforce this one until job003738 is resolved. */
  /* CHECKL(((klass->attr & AttrFMT) == 0) == (klass->walk == PoolNoWalk)); */
  if (klass != &CLASS_STATIC(AbstractCollectPool)) {
    CHECKL(((klass->attr & AttrGC) == 0) == (klass->fix == PoolNoFix));
    CHECKL(((klass->attr & AttrGC) == 0) == (klass->fixEmergency == PoolNoFix));
    CHECKL(((klass->attr & AttrGC) == 0) == (klass->reclaim == PoolNoReclaim));
  }
  
  CHECKS(PoolClass, klass);
  return TRUE;
}
コード例 #20
0
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  const char *format1 = "dirfile/format1";
  const char *format_data = "CdataD CONST UINT8 1\nINCLUDE format1 A Z\n";
  const char *format1_data = "data RAW UINT8 11\n";
  char *prefix;
  char *suffix;
  int fd, ret, e1, e2, r = 0;
  DIRFILE *D;

  rmdirfile();
  mkdir(filedir, 0777);

  fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
  write(fd, format_data, strlen(format_data));
  close(fd);

  fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666);
  write(fd, format1_data, strlen(format1_data));
  close(fd);

  D = gd_open(filedir, GD_RDWR);
  ret = gd_alter_affixes(D, 1, "C", "D");
  e1 = gd_error(D);
  gd_fragment_affixes(D, 1, &prefix, &suffix);
  e2 = gd_error(D);
  gd_close(D);

  unlink(format1);
  unlink(format);
  rmdir(filedir);

  CHECKS(prefix,"A");
  CHECKS(suffix,"Z");
  CHECKI(ret,-1);
  CHECKI(e1,GD_E_DUPLICATE);
  CHECKI(e2,0);
  free(prefix);
  free(suffix);

  return r;
}
コード例 #21
0
ファイル: madd_lincom.c プロジェクト: syntheticpp/dirfile
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  int error, ge_error, r = 0;
  gd_entry_t e;
  const char *in_fields[2] = {"in1", "in2"};
  const double m[2] = {1, 0.3};
  const double b[2] = {0, 0.9};
  DIRFILE *D;

  rmdirfile();
  D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
  gd_add_phase(D, "new", "in", 3, 0);
  gd_madd_lincom(D, "new", "meta", 2, in_fields, m, b);
  error = gd_error(D);

  /* check */
  gd_entry(D, "new/meta", &e);
  ge_error = gd_error(D);
  CHECKI(ge_error, 0);
  if (!r) {
    CHECKI(e.field_type, GD_LINCOM_ENTRY);
    CHECKI(e.fragment_index, 0);
    CHECKI(e.EN(lincom,n_fields), 2);
    CHECKS(e.in_fields[0], "in1");
    CHECKS(e.in_fields[1], "in2");
    CHECKF(e.EN(lincom,m)[0], m[0]);
    CHECKF(e.EN(lincom,m)[1], m[1]);
    CHECKF(e.EN(lincom,b)[0], b[0]);
    CHECKF(e.EN(lincom,b)[1], b[1]);
    CHECKI(e.comp_scal, 0);
    gd_free_entry_strings(&e);
  }

  gd_close(D);

  unlink(format);
  rmdir(filedir);

  CHECKI(error, 0);
  return r;
}
コード例 #22
0
ファイル: thix.c プロジェクト: Ravenbrook/mps
Bool ThreadCheck(Thread thread)
{
    CHECKS(Thread, thread);
    CHECKU(Arena, thread->arena);
    CHECKL(thread->serial < thread->arena->threadSerial);
    CHECKD_NOSIG(Ring, &thread->arenaRing);
    CHECKL(BoolCheck(thread->alive));
    CHECKD(PThreadext, &thread->thrextStruct);
    return TRUE;
}
コード例 #23
0
ファイル: message.c プロジェクト: S0043640wipro/RiCRiPInt
Bool MessageCheck(Message message)
{
  CHECKS(Message, message);
  CHECKU(Arena, message->arena);
  CHECKL(MessageTypeCheck(message->type));
  CHECKU(MessageClass, message->class);
  CHECKL(RingCheck(&message->queueRing));

  return TRUE;
}
コード例 #24
0
ファイル: vmw3.c プロジェクト: datafueled/memory-pool-system
Bool VMCheck(VM vm)
{
  CHECKS(VM, vm);
  CHECKL(vm->base != 0);
  CHECKL(vm->limit != 0);
  CHECKL(vm->base < vm->limit);
  CHECKL(vm->mapped <= vm->reserved);
  CHECKL(AddrIsAligned(vm->base, vm->align));
  CHECKL(AddrIsAligned(vm->limit, vm->align));
  return TRUE;
}
コード例 #25
0
ファイル: thxc.c プロジェクト: Ravenbrook/mps
Bool ThreadCheck(Thread thread)
{
  CHECKS(Thread, thread);
  CHECKU(Arena, thread->arena);
  CHECKL(thread->serial < thread->arena->threadSerial);
  CHECKD_NOSIG(Ring, &thread->arenaRing);
  CHECKL(BoolCheck(thread->alive));
  CHECKL(BoolCheck(thread->forking));
  CHECKL(MACH_PORT_VALID(thread->port));
  return TRUE;
}
コード例 #26
0
ファイル: splay.c プロジェクト: aseaday/mps-temporary
Bool SplayTreeCheck(SplayTree splay)
{
  UNUSED(splay);
  CHECKS(SplayTree, splay);
  CHECKL(FUNCHECK(splay->compare));
  CHECKL(FUNCHECK(splay->nodeKey));
  CHECKL(FUNCHECK(splay->updateNode));
  /* Can't use CHECKD_NOSIG because TreeEMPTY is NULL. */
  CHECKL(TreeCheck(splay->root));
  return TRUE;
}
コード例 #27
0
ファイル: traceanc.c プロジェクト: bhanug/mps
Bool TraceMessageCheck(TraceMessage tMessage)
{
  CHECKS(TraceMessage, tMessage);
  CHECKD(Message, TraceMessageMessage(tMessage));
  CHECKL(MessageGetType(TraceMessageMessage(tMessage)) ==
         MessageTypeGC);
  /* We can't check anything about the statistics.  In particular, */
  /* liveSize may exceed condemnedSize because they are only estimates. */

  return TRUE;
}
コード例 #28
0
ファイル: walk.c プロジェクト: BarAgent/mps-temporary
static Bool rootsStepClosureCheck(rootsStepClosure rsc)
{
  CHECKS(rootsStepClosure, rsc);
  CHECKD(ScanState, &rsc->ssStruct);
  CHECKL(FUNCHECK(rsc->f));
  /* p and s fields are arbitrary closures which cannot be checked */
  if (rsc->root != NULL) {
    CHECKD_NOSIG(Root, rsc->root); /* <design/check/#.hidden-type> */
  }
  return TRUE;
}
コード例 #29
0
ファイル: fragment_affix.c プロジェクト: syntheticpp/dirfile
int main(void)
{
  const char *filedir = "dirfile";
  const char *format = "dirfile/format";
  const char *format1 = "dirfile/format1";
  const char *format_data = "INCLUDE format1 A Z\n";
  const char *format1_data = "data RAW UINT8 11\n";
  char *prefix;
  char *suffix;
  int fd, ret, error, r = 0;
  DIRFILE *D;

  rmdirfile();
  mkdir(filedir, 0777);

  fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
  write(fd, format_data, strlen(format_data));
  close(fd);

  fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666);
  write(fd, format1_data, strlen(format1_data));
  close(fd);

  D = gd_open(filedir, GD_RDONLY | GD_VERBOSE);
  ret = gd_fragment_affixes(D, 1, &prefix, &suffix);
  error = gd_error(D);
  gd_close(D);

  unlink(format1);
  unlink(format);
  rmdir(filedir);

  CHECKS(prefix,"A");
  CHECKS(suffix,"Z");
  CHECKI(ret,0);
  CHECKI(error,0);
  free(prefix);
  free(suffix);

  return r;
}
コード例 #30
0
ファイル: arenacl.c プロジェクト: et4te/memory-pool-system
static Bool ClientChunkCheck(ClientChunk clChunk)
{
  Chunk chunk;

  CHECKS(ClientChunk, clChunk);
  chunk = ClientChunk2Chunk(clChunk);
  CHECKL(ChunkCheck(chunk));
  CHECKL(clChunk->freePages <= chunk->pages);
  /* check they don't overlap (knowing the order) */
  CHECKL((Addr)(chunk + 1) < (Addr)chunk->allocTable);
  return TRUE;
}