void *dumpTTyStat(int fd){ Sgttyb *sg; int err; sg = (Sgttyb*)STRUCT_ALLOC(sizeof(Sgttyb)); err = TC_getattr(fd,sg); return sg; }
/* Allocates a new object pool node for the given object header. */ static ObjPoolNode * objpoolnode_new(ObjPoolNode * next, void * data) { ObjPoolNode * self = STRUCT_ALLOC(ObjPoolNode); if(!self) return NULL; self->next = next; self->data = data; return self; }
static Sgttyb *STTY0(int fd,const char *command){ Sgttyb *tty; if( NO_TTY ) return 0; tty = (Sgttyb*)STRUCT_ALLOC( sizeof(*tty) ); cached_gtty(fd,tty); settty(fd,command); return tty; }
char *strpool_add(StrPool *pool, char *s) { char *p; if(!pool || !s) return NULL; if(!pool->dict) pool->dict = STRUCT_ALLOC(*pool->dict); p = strpool_find(pool,s); if(p) return p; p = strdup(s); hash_insert(pool->dict,p,p); return p; }
static int cached_gtty(int fd,Sgttyb *buf){ int xfd = (0 <= fd && fd < MAXFD) ? fd: MAXFD-1; int rcode; if( SG_ispeed(&cur_sgttyb[xfd]) == 0 ){ rcode = TCgetattr(fd,(Sgttyb*)&cur_sgttyb[xfd].SG); #ifdef hpux cur_sgttyb[xfd].SG_lflag = ICANON; #endif } if(initial_stty == 0){ initial_stty = (Sgttyb *) STRUCT_ALLOC( sizeof(*initial_stty) ); *initial_stty = cur_sgttyb[xfd]; } *buf = cur_sgttyb[xfd]; return 0; }
int strpool_read(char *fn, StrPool *pool, SerializeCtxt *ctxt) { StrBlock *sb; char *s; char *strblock = 0; int n; int i; File *fp = absfile_open_read(fn); if(!pool || !fp) return -1; assert(!pool->dict); pool->dict = STRUCT_ALLOC(*pool->dict); if(!int_binread(fp,&pool->dict->n_used) || !array_binread(fp,&pool->dict->elts,&pool->dict->n_elts)) // read the hashtable return -1; if(!array_binread(fp,&strblock,&n)) // blob of string data return -1; sb = calloc(sizeof(*sb),1); sb->block = strblock; sb->n = n; ap_push(&pool->strblocks,sb); // fixup s = strblock; for(i = 0; i < pool->dict->n_elts; ++i) { HashNode *node = pool->dict->elts + i; if(!node->key) continue; serialize_fixup_add_ptr(ctxt,node->key,s); node->key = s; s += strlen(s)+1; assert(s <= strblock + n); } return 0; }
/** Allocates a console. */ BBConsole * bbconsole_alloc() { return STRUCT_ALLOC(BBConsole); }
/* Allocates a widget */ BBWidget * bbwidget_allocate() { return STRUCT_ALLOC(BBWidget); }
Camera * camera_alloc() { return STRUCT_ALLOC(Camera); }
/** Allocates a Hatab. */ Hatab * hatab_alloc() { return STRUCT_ALLOC(Hatab); }
/* Allocates a new pail. */ static Pail * pail_alloc() { return STRUCT_ALLOC(Pail); }
/* Allocate a new hash tab pair. */ HatabPair * hatabpair_alloc() { return STRUCT_ALLOC(HatabPair); }
/** Allocates a Thing. */ Thing * thing_alloc() { return STRUCT_ALLOC(Thing); }