First, continue with your posted C. Using Newx (a malloc) will just leak the memory.
Second: put a debugging fprintf(stderr, "rados_pool_list()=%d\n", buf_sz); after the first rados_pool_list() call.

What does it print? A reasonable positive size? (I assume your C compiler is C99 capable; if not, you can rewrite the char buf[buf_sz]; as char *buf = alloca(buf_sz);).

Now, if rados_pool_list() returned a negative (error) value, try passing it "" in stead of NULL.
A quick glance at librados.cc makes me think there may be a bug there.

Oooomh, a quick update: another thing you should do is replace

  int buf_sz;
with a
  size_t buf_sz;
This, unfortunately will not improve the situation, since rados_pool_list() is prototyped as int, where it really ought to be ssize_t rados_pool_list(). File a ticket with the project?


In reply to Re: [Ceph::RADOS] Help Debugging Inline C by oiskuu
in thread [Ceph::RADOS] Help Debugging Inline C by three18ti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.