rem: DBG("qm_malloc(%x, %d) called from %s: %s(%d)\n", qm, size, file, func,
add: DBG("qm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
context: void* qm_malloc(struct qm_block* qm, unsigned int size)#endif{	struct qm_frag* f;	struct qm_frag_end* end;	struct qm_frag* n;	unsigned int rest;	#ifdef DBG_QM_MALLOC	unsigned int list_cntr;	list_cntr = 0;	DBG("qm_malloc(%x, %d) called from %s: %s(%d)\n", qm, size, file, func,			line);#endif	/*size must be a multiple of 8*/	size=ROUNDUP(size);	if (size>(qm->size-qm->real_used)) return 0;	/*search for a suitable free frag*/	if ((f=qm_find_free(qm, size))!=0){		/* we found it!*/		/*detach it from the free list*/#ifdef DBG_QM_MALLOC			qm_debug_frag(qm, f);#endif		qm_detach_free(qm, f);		/*mark it as "busy"*/		f->u.is_free=0;				/*see if we'll use full frag, or we'll split it in 2*/		rest=f->size-size;		if (rest>(FRAG_OVERHEAD+MIN_FRAG_SIZE)){			f->size=size;			/*split the fragment*/			end=FRAG_END(f);			end->size=size;			n=(struct qm_frag*)((char*)end+sizeof(struct qm_frag_end));			n->size=rest-FRAG_OVERHEAD;			FRAG_END(n)->size=n->size;			qm->real_used+=FRAG_OVERHEAD;#ifdef DBG_QM_MALLOC			end->check1=END_CHECK_PATTERN1;			end->check2=END_CHECK_PATTERN2;			/* frag created by malloc, mark it*/			n->file=file;			n->func="frag. from qm_malloc";			n->line=line;			n->check=ST_CHECK_PATTERN;/*			FRAG_END(n)->check1=END_CHECK_PATTERN1;			FRAG_END(n)->check2=END_CHECK_PATTERN2; */#endif			/* reinsert n in free list*/			qm_insert_free(qm, n);		}else{			/* we cannot split this fragment any more => alloc all of it*/		}		qm->real_used+=f->size;		qm->used+=f->size;		if (qm->max_real_used<qm->real_used)			qm->max_real_used=qm->real_used;#ifdef DBG_QM_MALLOC		f->file=file;		f->func=func;		f->line=line;		f->check=ST_CHECK_PATTERN;		/*  FRAG_END(f)->check1=END_CHECK_PATTERN1;			FRAG_END(f)->check2=END_CHECK_PATTERN2;*/		DBG("qm_malloc(%x, %d) returns address %x on %d -th hit\n", qm, size,			(char*)f+sizeof(struct qm_frag), list_cntr );#endif		return (char*)f+sizeof(struct qm_frag);	}	return 0;}