int lc = 0; while (c  && (lc++ < q->num) && (ans = nextValue(c))) { newValArray[count++] = (char*) ans;
int lc = 0; while (c  && (lc++ <= q->num) && (ans = nextValue(c))) { newValArray[count] = (char*) ans; count++;
processRDFQuery (char* query) {    RDF_Resource root;    int          numSegments;    int count = 0;    char** ans = NULL;    QuerySegment* querySegments = parseQuery(query, &root, &numSegments);    int          n = 0;    QuerySegment current = NULL;    QuerySegment prev    = NULL;    char** currentValArray = (char**)getMem(sizeof(RDF_Resource)*2);    char** newValArray     = (char**)getMem(4096 * sizeof(RDF_Resource));    currentValArray[0] = (char*) root;    for (n = 0; n < numSegments; n++) {      QuerySegment q = querySegments[n];           int nc = 0;      int ansType = ((n == numSegments-1) ? RDF_STRING_TYPE : RDF_RESOURCE_TYPE);	  count = 0;      for (nc = 0; currentValArray[nc] != NULL; nc++) {	    RDF_Cursor c = getSlotValues(NULL, (RDF_Resource)currentValArray[nc], q->s,                                      ansType, q->inversep, 1);	    RDF_Resource ans;		int lc = 0;	    while (c  && (lc++ < q->num) && (ans = nextValue(c))) {          newValArray[count++] = (char*) ans;	    }        if (c) disposeCursor(c);      }      freeMem(currentValArray);      currentValArray = newValArray;      newValArray = (char**) getMem(4096 * sizeof(RDF_Resource));    }	freeMem(newValArray);    if (count > 0) {      ans = (char**)getMem((count+1) * sizeof(char*));      memcpy(ans, currentValArray, (count * sizeof(char*)));    }    freeMem(currentValArray);    for (n = 0; n < numSegments; n++) freeMem(querySegments[n]);         return ans;}