Home | History | Annotate | Download | only in dec

Lines Matching defs:mem

81 static inline size_t MemDataSize(const MemBuffer* mem) {
82 return (mem->end_ - mem->start_);
89 MemBuffer* const mem = &idec->mem_;
92 assert(mem->mode_ == MEM_MODE_APPEND);
94 if (mem->end_ + data_size > mem->buf_size_) { // Need some free memory
97 const int num_chunks = (MemDataSize(mem) + data_size + CHUNK_SIZE - 1)
100 const uint8_t* const base = mem->buf_ + mem->start_;
104 memcpy(new_buf, base, MemDataSize(mem));
115 free(mem->buf_);
116 mem->buf_ = new_buf;
117 mem->buf_size_ = new_size;
119 mem->end_ = MemDataSize(mem);
120 mem->start_ = 0;
123 memcpy(mem->buf_ + mem->end_, data, data_size);
124 mem->end_ += data_size;
125 assert(mem->end_ <= mem->buf_size_);
126 dec->parts_[last_part].buf_end_ = mem->buf_ + mem->end_;
130 idec->io_.data = mem->buf_ + mem->start_;
131 idec->io_.data_size = MemDataSize(mem);
138 MemBuffer* const mem = &idec->mem_;
141 const uint8_t* base = mem->buf_;
143 assert(mem->mode_ == MEM_MODE_MAP);
144 if (data_size < mem->buf_size_) {
162 mem->buf_ = (uint8_t*)data;
163 mem->end_ = mem->buf_size_ = data_size;
170 static void InitMemBuffer(MemBuffer* const mem) {
171 mem->mode_ = MEM_MODE_NONE;
172 mem->buf_ = 0;
173 mem->buf_size_ = 0;
174 mem->part0_buf_ = 0;
175 mem->part0_size_ = 0;
178 static void ClearMemBuffer(MemBuffer* const mem) {
179 assert(mem);
180 if (mem->mode_ == MEM_MODE_APPEND) {
181 free(mem->buf_);
182 free((void*)mem->part0_buf_);
186 static int CheckMemBufferMode(MemBuffer* const mem, MemBufferMode expected) {
187 if (mem->mode_ == MEM_MODE_NONE) {
188 mem->mode_ = expected; // switch to the expected mode
189 } else if (mem->mode_ != expected) {
192 assert(mem->mode_ == expected); // mode is ok
278 MemBuffer* const mem = &idec->mem_;
279 assert(!mem->part0_buf_);
281 assert(psize <= mem->part0_size_);
282 if (mem->mode_ == MEM_MODE_APPEND) {
289 mem->part0_buf_ = part0_buf;
290 mem->start_ += psize;