int xferLastResultBuffer(CMPIResult *result, int to, int rc) { NativeResult *r = (NativeResult*) result; _SFCB_ENTER(TRACE_PROVIDERDRV, "xferLastResultBuffer"); rc=xferResultBuffer(r,to,0,rc, 1); /* passing 1 should be fine */ _SFCB_RETURN(rc); }
/* * find the next position where we can stick the next object of type that * is 'length' long in 'nr'. If necessary, send what's in the buffer * already. */ static void * nextResultBufferPos(NativeResult * nr, int type, int length) { long pos, npos; _SFCB_ENTER(TRACE_PROVIDERDRV, "nextResultBufferPos"); if (nr->data == NULL) prepResultBuffer(nr, length); /* * if there won't be enough room, send it off or make nr->data bigger */ if (nr->dNext + length >= nr->dMax) { /* * either we aren't chunking or length > buffer size */ if (!nr->requestor || length >= nr->dMax) { while (nr->dNext + length >= nr->dMax) nr->dMax *= 2; nr->data = (char *) realloc(nr->data, nr->dMax); } /* * xfering current contents to make enough room */ else { xferResultBuffer(nr, nr->requestor, 1, 1, length); nr->dNext = 0; nr->sNext = 0; } } if (nr->sNext == nr->sMax) { nr->sMax *= 2; nr->resp = (BinResponseHdr *) realloc(nr->resp, sizeof(BinResponseHdr) + ((nr->sMax - 1) * sizeof(MsgSegment))); } /* * store the pointer to the location within nr->data where this object * will be */ nr->resp->object[nr->sNext].data = (void *) nr->dNext; nr->resp->object[nr->sNext].length = length; nr->resp->object[nr->sNext++].type = type; pos = nr->dNext; nr->dNext += length; /* set the position for next object after * this one. ready for memcpy */ npos = (long) (nr->data + pos); _SFCB_RETURN((void *) npos); }