コード例 #1
0
ファイル: libconfig.c プロジェクト: aveek0218/ImpalaPythia
LIBCONFIG_API void config_init(config_t *config)
{
  memset((void *)config, 0, sizeof(config_t));

  config->root = _new(config_setting_t);
  config->root->type = CONFIG_TYPE_GROUP;
  config->root->config = config;
}
コード例 #2
0
String::String (char const* str, int length)
{
  buf = _new (length + 1);
  _len (buf) = length;
  _ref (buf) = 1;
  if (str)
    memcpy (buf, str, length);
  buf[length] = 0;
}
コード例 #3
0
void String::splice ()
{
  char* tmp = _new (_size (buf));
  _len (tmp) = _len (buf);
  _ref (tmp) = 1;
  memcpy (tmp, buf, _len (buf) + 1);
  deref ();
  buf = tmp;
}
コード例 #4
0
ファイル: context-info-db.c プロジェクト: pzoleex/syslog-ng
ContextInfoDB *
context_info_db_new()
{
  ContextInfoDB *self = g_new0(ContextInfoDB, 1);

  _new(self);

  return self;
}
コード例 #5
0
/*static*/
void ComServicePartitionResult::Create(
    __out ComServicePartitionResult::SPtr& spResult,
    __in KAllocator& allocator,
    __in KString& result
)
{
    spResult = _new(TAG, allocator) ComServicePartitionResult(result);
    KInvariant(spResult != nullptr);
}
コード例 #6
0
ファイル: libconfig.c プロジェクト: kopasiak/libconfig
void config_init(config_t *config)
{
  memset((void *)config, 0, sizeof(config_t));

  config->root = _new(config_setting_t);
  config->root->type = CONFIG_TYPE_GROUP;
  config->root->config = config;
  config->tab_width = 2;
  config->output_format = CONFIG_OUT_FORMAT_DEFAULT;
}
コード例 #7
0
/*static*/
void DnsHealthMonitor::Create(
    __out DnsHealthMonitor::SPtr& spHealth,
    __in KAllocator& allocator,
    __in const DnsServiceParams& params,
    __in IFabricStatelessServicePartition2& fabricHealth
)
{
    spHealth = _new(TAG, allocator) DnsHealthMonitor(params, fabricHealth);
    KInvariant(spHealth != nullptr);
}
コード例 #8
0
String String::printf (char const* fmt, ...)
{
  va_list ap;
  va_start (ap, fmt);

  char* buf = _new (_vscprintf (fmt, ap) + 1);
  _len (buf) = _size (buf) - 1;
  _ref (buf) = 1;
  vsprintf (buf, fmt, ap);
  return frombuf (buf);
}
コード例 #9
0
String::String (char const* str)
{
  int len = str ? (int) strlen (str) : 0;
  buf = _new (len + 1);
  _len (buf) = len;
  _ref (buf) = 1;
  if (str)
    memcpy (buf, str, len + 1);
  else
    buf[0] = 0;
}
コード例 #10
0
ファイル: .c プロジェクト: pigay/vsg
vsg_quaternion@t@_vector3@alt_t@_new (const VsgVector3@alt_t@ *vector)
{
#ifdef VSG_CHECK_PARAMS
  g_return_val_if_fail (vector != NULL, NULL);
#endif

  return vsg_quaternion@t@_new ((@type@) vector->x,
                                (@type@) vector->y,
                                (@type@) vector->z,
                                (@type@) 1.);
}
コード例 #11
0
ファイル: freeze.hpp プロジェクト: charlesw1234/learning
 Document_t<VALUE_T>::Document_t(const Document_t<VALUE_T> *doc, uint32_t pos)
 {
     if (doc->IsRemoved(pos)) { body = NULL; types = NULL; values = NULL; strings = NULL; }
     else {
         FreezeCount_t<VALUE_T> countobj;
         countobj.recur_count(doc, pos);
         if (!_new(&countobj)) return;
         FreezeFill_t<VALUE_T> fillobj(types, values, strings);
         fillobj.recur_fill(doc, pos, 0);
     }
 }
コード例 #12
0
ファイル: bst.cpp プロジェクト: jzsun/work
void
createRec (BST * root, int d)
{
  if (root)
    {
      if (d > root->data)
	{
	  if (root->right)
	    createRec (root->right, d);
	  else
	    root->right = _new (d);
	}
      else if (d < root->data)
	{
	  if (root->left)
	    createRec (root->left, d);
	  else
	    root->left = _new (d);
	}
    }
}
コード例 #13
0
ファイル: libconfig.c プロジェクト: krin-san/libconfig
void config_init(config_t *config)
{
  memset((void *)config, 0, sizeof(config_t));

  config->root = _new(config_setting_t);
  config->root->type = CONFIG_TYPE_GROUP;
  config->root->config = config;
  config->options = (CONFIG_OPTION_SEMICOLON_SEPARATORS
                     | CONFIG_OPTION_COLON_ASSIGNMENT_FOR_GROUPS
                     | CONFIG_OPTION_OPEN_BRACE_ON_SEPARATE_LINE);
  config->tab_width = 2;
}
コード例 #14
0
ファイル: address_space.c プロジェクト: 8l/kestrel
static
AddressSpace *
make(Options *opts) {
	AddressSpace *as = _new();
	FILE *romFile;
	int n, overflow;

	assert(opts);
	assert(opts->romFilename);

	as->rom = (UBYTE *)malloc(ROM_SIZE);
	memset(as->rom, 0, ROM_SIZE);
	romFile = fopen(opts->romFilename, "rb");
	if(!romFile) {
		fprintf(stderr, "Cannot open ROM file %s\n", opts->romFilename);
		exit(1);
	}
	n = fread(as->rom, 1, ROM_SIZE, romFile);
	if(n == ROM_SIZE) {
		n = fread(&overflow, 1, 1, romFile);
		if(n == 1) {
			fprintf(stderr, "ROM file is too big; should be %ld bytes.\n", ROM_SIZE);
			fclose(romFile);
			exit(1);
		}
	}
	fclose(romFile);

	as->ram = (UBYTE *)malloc(PHYS_RAM_SIZE);
	if(!as->ram) {
		fprintf(stderr, "Cannot allocate physical RAM for emulated computer.\n");
		exit(1);
	}

	for(n = 0; n < MAX_DEVS; n++) {
		as->writers[n] = no_writer;
		as->readers[n] = no_reader;
	}
	as->readers[15] = rom_reader;
	as->writers[0] = ram_writer;
	as->readers[0] = ram_reader;
	as->writers[14] = uart_writer;
	as->readers[14] = uart_reader;

	for(n = 0; n < MAX_DEVS; n++) {
		assert(as->writers[n]);
		assert(as->readers[n]);
	}
	assert(as->rom);
	assert(as->ram);
	return as;
}
コード例 #15
0
ファイル: pipe1.c プロジェクト: ABratovic/open-watcom-v2
extern void pipe3d_init(
/**********************/
    pipe_view   *view,
    pipe_illum  *illum,
    bool        all_poly_convex
) {
    set_view_trans_mat( view );
    set_illumination( illum );
    set_poly_convex_info( all_poly_convex );

    _new( Pipe3dList, 1 );
    rend_list_init( Pipe3dList );
}
コード例 #16
0
ファイル: compress.c プロジェクト: ZachLiss/Pittar
byte* lzw_encode(byte *in, int max_bits) {
	int len = _len(in), bits = 9, next_shift = 512;
	ushort code, c, nc, next_code = M_NEW;
	lzw_enc_t *d = _new(lzw_enc_t, 512);
 
	if (max_bits > 16) max_bits = 16;
	if (max_bits < 9 ) max_bits = 12;
 
	byte *out = _new(ushort, 4);
	int out_len = 0, o_bits = 0;
	uint32_t tmp = 0;
 
	inline void write_bits(ushort x) {
		tmp = (tmp << bits) | x;
		o_bits += bits;
		if (_len(out) <= out_len) _extend(out);
		while (o_bits >= 8) {
			o_bits -= 8;
			out[out_len++] = tmp >> o_bits;
			tmp &= (1 << o_bits) - 1;
		}
	}
コード例 #17
0
ファイル: Server.cpp プロジェクト: neo333/TesinaRc_AuthProt
void Server::OpenConnection(const Uint16 port_num) throw(const char*){
	if(port_num!=0) this->port_number=port_num;
	if(SDLNet_ResolveHost(&this->indirizzo_ip,NULL,this->port_number)!=0){
		throw SDLNet_GetError();
	}

	Data_scriptClient _new(0,NULL,NULL);
	_new.connessione=SDLNet_TCP_Open(&this->indirizzo_ip);
	this->connessioni[0]=_new;
	this->server=this->connessioni[0].connessione;
	if(this->server==NULL){
		throw SDLNet_GetError();
	}
}
コード例 #18
0
ファイル: adict.c プロジェクト: sk4zuzu/libadict
adict_tup_t adict_insert(adict_t*adict_p,char*keystr){
    adict_tup_t tuple=adict_search(adict_p,keystr);

    if(tuple.find_p){
        return_EMPTY_TUPLE;
    }

    adict_node_t*search_p=_new(keystr);

    if(!search_p){
        return_EMPTY_TUPLE;
    }

    tuple.find_p=search_p;

    if(tuple.prev_p){
        adict_node_t*parent_p=tuple.prev_p;

        if(memcmp(keystr,parent_p->key.data,
                         parent_p->key.size) < 0){
            parent_p->left_p=search_p;
        }else{
            parent_p->rght_p=search_p;
        }
    }else{
        adict_p->root_p=search_p;
    }

    search_p->prev_p=tuple.prev_p;
    search_p->left_p=NULL;
    search_p->rght_p=NULL;
    search_p->prio=urand32();

    // BALANCE THE BST

    while(search_p->prev_p){
        adict_node_t*parent_p=search_p->prev_p;

        if(search_p->prio <= parent_p->prio){
            break;
        }

        _rotate(adict_p,tuple.find_p);
    }

    adict_p->count++;

    tuple.prev_p=search_p->prev_p;
    return tuple;
}
コード例 #19
0
ファイル: splay_tree.cpp プロジェクト: calcu16/P
static new_node_return new_node(FatPointer<int> value)
{
    new_node_return __return__;
    /// node new = malloc(sizeof(struct node));
    struct_node temp;
    node _new(temp);
    /// new->value_ = value;
    _new->value_ = value;
    /// new->children_[0] = new->children_[1] = NULL;
    _new->children_[0] = NULL;
    _new->children_[1] = NULL;
    /// return new;
    __return__.value = _new;
    return __return__;
}
コード例 #20
0
/*static*/
void DnsExchangeOp::Create(
    __out DnsExchangeOp::SPtr& spExchangeOp,
    __in KAllocator& allocator,
    __in IDnsTracer& tracer,
    __in IDnsParser& dnsParser,
    __in INetIoManager& netIoManager,
    __in IUdpListener& udpServer,
    __in IFabricResolve& fabricResolve,
    __in INetworkParams& networkParams,
    __in const DnsServiceParams& params
)
{
    spExchangeOp = _new(TAG, allocator) DnsExchangeOp(tracer, dnsParser, netIoManager, udpServer, fabricResolve, networkParams, params);
    KInvariant(spExchangeOp != nullptr);
}
コード例 #21
0
void String::realloc (int newlen)
{
  newlen++;
  if (newlen <= _size (buf))
    return;
  int newsize = (_size (buf) < ALLOC_STEP ? _size (buf) * 2 : _size (buf) + ALLOC_STEP);
  if (newsize < newlen)
    newsize = newlen;
  char* tmp = _new (newsize);
  _len (tmp) = _len (buf);
  _ref (tmp) = _ref (buf);
  memcpy (tmp, buf, _len (buf) + 1);
  _del (buf);
  buf = tmp;
}
コード例 #22
0
ファイル: RlxMTimer.c プロジェクト: jonyMarino/microsdhacel
/*
** ===================================================================
**     Method     : RlxMTimer_Construct
**    Description : Constructor del Objeto
** ===================================================================
*/
void RlxMTimer_Construct(void * _self,ulong tiempo,   void (*pf)(void*),void * Obj ){
void * p_tmp;
struct RlxMTimer * _mt=_self;
void *thread;  
  
  MTimer_Construct(_self,tiempo,pf,Obj);
  _mt->execute=FALSE;
  
  if(!_RlxMTCont){    
    _RlxMTCont=_new(&LinkedList);
    pthread_create(&thread,NULL,RlxMTimer_Handler,NULL);
  }
  
  LinkedList_add(_RlxMTCont,_self);

}
コード例 #23
0
/*
** ===================================================================
**     Method     : DobleList_InsertFirst 
**    Description : Inserta un dato al principio de la Lista
** ===================================================================
*/
struct NodoDbl * DobleList_InsertFirst(void * _self,void * dato){
  struct DobleList * _l= _self;
  struct NodoDbl * _n = _new(&NodoDbl,dato,_l->_Nodo,NULL);
  
  if(!_n)
    return NULL;
  
  if(_l->_Nodo){
    _l->_Nodo->prev=_n;
    ((struct Nodo*)_n)->next=_l->_Nodo;  
  }
  
  _l->_Nodo=_n;
  
  return _n;
}
コード例 #24
0
ファイル: display.c プロジェクト: Bouke/Pillow
PyObject*
PyImaging_DisplayWin32(PyObject* self, PyObject* args)
{
    ImagingDisplayObject* display;
    char *mode;
    int xsize, ysize;

    if (!PyArg_ParseTuple(args, "s(ii)", &mode, &xsize, &ysize))
	return NULL;

    display = _new(mode, xsize, ysize);
    if (display == NULL)
	return NULL;

    return (PyObject*) display;
}
コード例 #25
0
String String::substr (int from, int len) const
{
  if (from < 0) from += _len (buf);
  if (from < 0) from = 0;
  if (from > _len (buf)) from = _len (buf);
  if (len == toTheEnd) len = _len (buf) - from;
  else if (len < 0) len += _len (buf) - from;
  else if (from + len > _len (buf)) len = _len (buf) - from;
  if (len < 0) len = 0;
  char* str = _new (len + 1);
  _len (str) = len;
  _ref (str) = 1;
  if (len)
    memcpy (str, buf + from, len);
  str[len] = 0;
  return frombuf (str);
}
コード例 #26
0
NTSTATUS
FileObjectTable::Create(
    __in KAllocator& Allocator,
    __in ULONG AllocationTag,
    __out FileObjectTable::SPtr& FOT
    )
{
    NTSTATUS status = STATUS_SUCCESS;
    FileObjectTable::SPtr fot;

    FOT = nullptr;
    
    fot = _new(AllocationTag, Allocator) FileObjectTable();
    if (fot == nullptr)
    {
        KTraceOutOfMemory( 0, STATUS_INSUFFICIENT_RESOURCES, 0, 0, 0);
        return(STATUS_INSUFFICIENT_RESOURCES);
    }

    if (! NT_SUCCESS(fot->Status()))
    {
        return(fot->Status());
    }

    OverlayManager::SPtr overlayManager;

    LookupOverlayManager(Allocator, overlayManager);
    
    if (overlayManager)
    {
        fot->_OverlayManager = overlayManager;
    } else {
#if DBG
        KInvariant(FALSE);   // Don't bring machine down unless debugging
#endif
        status = STATUS_INTERNAL_ERROR;
        KTraceFailedAsyncRequest(status, NULL, 0, 0);
    }       
    
    fot->_ObjectIdIndex = 1;
    
    FOT = Ktl::Move(fot);
    
    return(status);
}
コード例 #27
0
ファイル: mp3taggerDlg.cpp プロジェクト: przemeklal/mp3tagger
void Cmp3taggerDlg::OnEnChangeEditTitle()
{

	if (theApp.filesInProgram == 0)
	{
		AfxMessageBox(L"Brak otwartych plików.", MB_OK, MB_ICONWARNING);
		return;
	}

	this->UpdateData();
	theApp.unsavedChanges = TRUE;
	CString _Cnew;
	GetDlgItemText(IDC_EDIT_TITLE, _Cnew);
	CT2A _new(_Cnew);
	TRACE(_T("%S"), _new.m_psz);
	theApp.selected->SetTitle(_new);
	this->UpdateData(FALSE);
}
コード例 #28
0
void  SenRpm_Construct(struct SensorRpm * self,ThreadAttachable::ThreadAttacher* adj,uint tiempoDeMuestreo,struct Capturador * capturador,const SensorRpmConf * conf,const char * desc){
//  while(!_AD_isnew(adc)) //Espera a q haya una conversión
//    WDog1_Clear();
  
  Sensor_constructor(self);
  _SensorVisual_setDescription(self,desc);
  //tiempoDeMuestreo=5*tiempoDeMuestreo;
  self->conf=conf; 
  self->capturador=capturador;
  self->bufferFiltro=0;
 // self->buffer=0;
  Capturador_Comenzar(capturador);
  newAlloced(&self->timerMuestreo,&RlxMTimer,(ulong)tiempoDeMuestreo,SenRpm_procesarCaptura,self);
  //AdjuntadorAHilo_adjuntar(adj,SenRpm_procesar,self);
  struct Method * methodObj=(struct Method *) _new(&Method,SenRpm_procesar,self);
  (adj)->adjuntar(methodObj);
  self->onNewVal=NULL;
  self->state= SENSOR_OK;
  self->ContadorUf=0;
}
コード例 #29
0
FileObjectTable::FileObjectTable(
    ) :
   _Table(FileObjectEntry::GetLinksOffset(),
          KNodeTable<FileObjectEntry>::CompareFunction(&FileObjectEntry::Comparator)),
   _RequestList(FIELD_OFFSET(RequestMarshallerKernel, _ListEntry)),
   _IoBufferElementList(FIELD_OFFSET(KIoBufferElementKernel, _ListEntry))
{
    _LookupKey = _new(GetThisAllocationTag(), GetThisAllocator()) FileObjectEntry();
    if (! _LookupKey)
    {
        KTraceOutOfMemory( 0, STATUS_INSUFFICIENT_RESOURCES, 0, 0, 0);
        SetConstructorStatus(STATUS_INSUFFICIENT_RESOURCES);
        return;
    }

    if (! NT_SUCCESS(_LookupKey->Status()))
    {
        SetConstructorStatus(_LookupKey->Status());     
    }        
}
コード例 #30
0
ファイル: window.c プロジェクト: ABratovic/open-watcom-v2
float _wtextmaxwidth(
/*******************/

    int                 num_chars,
    text_def            *text
) {
    char                *ptr;
    float               width;

    _new( ptr, num_chars + 1 );

    memset( ptr, 'M', num_chars );
    ptr[num_chars] = '\0';

    width = _wtextwidth( ptr, text );

    _free( ptr );

    return( width );
}