Dynamic File_obj::__Field(const ::String &inName,bool inCallProp) { switch(inName.length) { case 4: if (HX_FIELD_EQ(inName,"read") ) { return read_dyn(); } if (HX_FIELD_EQ(inName,"copy") ) { return copy_dyn(); } break; case 5: if (HX_FIELD_EQ(inName,"write") ) { return write_dyn(); } break; case 6: if (HX_FIELD_EQ(inName,"append") ) { return append_dyn(); } break; case 8: if (HX_FIELD_EQ(inName,"getBytes") ) { return getBytes_dyn(); } break; case 9: if (HX_FIELD_EQ(inName,"saveBytes") ) { return saveBytes_dyn(); } if (HX_FIELD_EQ(inName,"file_open") ) { return file_open; } break; case 10: if (HX_FIELD_EQ(inName,"getContent") ) { return getContent_dyn(); } break; case 11: if (HX_FIELD_EQ(inName,"saveContent") ) { return saveContent_dyn(); } break; case 13: if (HX_FIELD_EQ(inName,"file_contents") ) { return file_contents; } } return super::__Field(inName,inCallProp); }
/* * Allocate space in the dynamic pool */ CVmPoolDynObj *CVmPoolInMem::dynpool_alloc(size_t len) { CVmPoolDynObj *cur; /* * if the requested size exceeds the page size, we can't allocate * it, since each request must fit within a single page */ if (len > page_size_) return 0; /* * First, see if we can find a free pool object that we've already * allocated that will fill the request */ for (cur = dyn_head_ ; cur != 0 ; cur = cur->get_next()) { /* if this object is free, and it's big enough, use it */ if (cur->is_free() && cur->get_len() >= len) { /* * if this object is at least a little bigger than the * request, create a new object to hold the balance of this * object, so that the balance can be allocated separately */ if (cur->get_len() > len + 63) { CVmPoolDynObj *new_obj; /* * create a new object, using the space remaining in the * old object after the requested amount of space */ new_obj = new CVmPoolDynObj(cur->get_ofs() + len, cur->get_len() - len); /* reduce the old object to the requested size */ cur->set_len(len); /* link the new object in after the old object */ insert_dyn(cur, new_obj); /* the new object is free */ new_obj->set_free(TRUE); } /* this object is now in use */ cur->set_free(FALSE); /* return the object we found */ return cur; } } /* * We didn't find any free memory in any existing pages where we * could fill the request. So, we must allocate a new page. First, * allocate a new page slot. */ alloc_page_slots(page_slots_ + 1); /* allocate space for the page data */ pages_[page_slots_ - 1].mem = (char *)t3malloc(page_size_); /* * if the requested size wouldn't leave much additional space on the * page, simply give the entire page to the new object */ if (len + 63 >= page_size_) len = page_size_; /* create a new dynamic pool handle for the new object */ cur = new CVmPoolDynObj(get_page_start_ofs(page_slots_ - 1), len); /* link it in at the end of the list */ append_dyn(cur); /* * if there's any space left over, create yet another object to * cover the free space remaining on the page */ if (len < page_size_) { CVmPoolDynObj *f; /* create a new dynamic pool handle for the new object */ f = new CVmPoolDynObj(get_page_start_ofs(page_slots_ - 1) + len, page_size_ - len); /* mark it as free */ f->set_free(TRUE); /* link it in at the end of the list */ append_dyn(f); } /* return the new object */ return cur; }