/* * Internal Function: Search for the freeslot in the sub record array * * Parameters: * lr - Parent ldt_record * * Return value: * >=0 if empty slot found * -1 in case not found * * Description: * The function walks through the lchunk array searching for * the request digest. * * Callers: * ldt_aerospike_crec_open * ldt_aerospike_crec_create */ ldt_slot * slot_lookup_free(ldt_record *lrecord, char *func) { if (lrecord->num_slots_used == (lrecord->max_chunks * LDT_SLOT_CHUNK_SIZE)) { if (expand_chunk(lrecord)) { goto Out; } } for (int i = 0; i < lrecord->max_chunks; i++) { ldt_slot_chunk *chunk = &lrecord->chunk[i]; for (int j = 0; j < LDT_SLOT_CHUNK_SIZE; j++) { if (!chunk->slots[j].inuse) { lrecord->num_slots_used++; chunk->slots[j].inuse = true; cf_detail(AS_LDT, "%s Popped slot %p %"PRIu64"", func, &chunk->slots[j], lrecord->num_slots_used); return &chunk->slots[j]; } } } Out: cf_warning(AS_LDT, "%s: Allocation Error [Cannot open more than (%"PRIu64") Sub-Records in a single UDF]... Fail", func, lrecord->num_slots_used); return NULL; }
buffer& buffer::put(const char content, Boolean exp_buf) { //return put((char*)&content, sizeof(content)); if ( v_bufsz == content_sz() ) { if ( exp_buf == true ) expand_chunk(v_bufsz + 10); else { MESSAGE( cerr, "buffer::put(const char): overflow"); throw ( CASTBNDEXCEPT boundaryException(content_sz(), v_bufsz, 1) ); } } *v_eptr = content; v_eptr++; return *this; }
buffer& buffer::put(const char* content, int sz, Boolean exp_buf) { if ( sz > v_bufsz - content_sz() ) { if ( exp_buf == true ) expand_chunk(v_bufsz + sz); else { MESSAGE( cerr, "buffer::put(char*, int): overflow"); throw ( CASTBNDEXCEPT boundaryException(content_sz(), v_bufsz, sz) ); } } //memcpy(v_eptr, content, sz); //debug(cerr, int(v_base)); //debug(cerr, int(v_eptr)); for ( int i=0; i<sz; i++ ) { v_eptr[i] = content[i]; //debug(cerr, int(v_eptr[i])); } v_eptr += sz; return *this; }