In no particular order:
#define should not be placed in a function like that, define at file scope. In this case it seems unnecessary since you could declare it as a constant instead since it is used for dynamic allocation.
const size_t maxSize = 64;
always initialize all variables, just in case.
char* str = NULL;
char* pos = NULL;
you malloc should just take
size as argument i.e.
malloc(size) the rest makes it just look difficult to read and in this case is wrong, same applies to
in general it is better to write functions that do not force the user of them to look at the implementation in order to figure out how to use them.
your function allocates memory and returns a buffer that the user needs to free. this fact is not obvious from the function name (it could have returned a ptr to a static buffer for instance, or a pointer to a global array whatever).
you should check the return value of
realloc, it is not always successful. you need to deal with that event as well. e.g. reading many lines and with a memory that is fragmented may cause it to fail to find a large enough continuous memory block.
realloc also is an expensive function to call, it is better to allocate larger blocks than try to allocate several small blocks.
your function can fail in a few ways but you only set the
*error when malloc fails, you may want to add some more error codes like when nothing is read.
EDIT: removed fgets comment.