|sockGetStringFrom| uses a fixed buffer length of 10000,
which is wasteful if the string is small, and is wrong if
the string length exceeds it.

I think we can improve with things like:

char *
sock_get_string_aux(int purpose, char * buf, int buf_len)
{
  if (accept_if_needed(purpose) != -1) {
    val = fill_buf(purpose_table[purpose], buf, buf_len);
    if (val == -1)
      return NULL;
    return buf;
  }
  return NULL;
}

====

(defun |sockGetStringFrom| (purpose)
    (sockGetStringAux purpose (|sockGetInt| purpose)))

#+(and :clisp :ffi)
(defun sockGetStringAux (purpose len)
    (ffi:with-foreign-object (buf '(ffi:c-array-max ffi:character len))
        (sock_get_string_aux purpose buf len)
        (ffi:foreign-value buf)))

- Qian

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/19d884b6-7fb0-41a8-8d43-a9b2d79427b5%40gmail.com.

Reply via email to