add indexOf method
[ecparse.git] / GrowingBuffer.cpp
index a260a3d..8e3bd4a 100644 (file)
@@ -98,3 +98,13 @@ void GrowingBuffer::resize(double factor) {
        }
 }
 
+size_t GrowingBuffer::indexOf(char c, size_t start) {
+       void* foundIndex;
+
+       foundIndex = memchr((ptrdiff_t*) data + position + start, c, (limit - start));
+       if (foundIndex) {
+               return (ptrdiff_t) foundIndex - ((ptrdiff_t) data + position);
+       }
+       return -1;
+}
+