Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Zookeeper >> mail # user >> The problem of using c binding function


+
吴腾飞 2013-10-12, 02:08
Copy link to this message
-
Re: The problem of using c binding function
Likely because data in the second case is allocated on the stack,
which goes out of scope asa you exit the method.

Patrick

On Fri, Oct 11, 2013 at 7:08 PM, 吴腾飞 <[EMAIL PROTECTED]> wrote:
> Hi
>
>
>
> I using c client binding fuction zoo_aget,the passed data cause problem.
>
>
>
> ZOOAPI int zoo_aget(zhandle_t *zh,const char *path,int
> watch,data_completion_t completion,const void *data)
>
>
>
> 1.Using like this is ok:
>
>
>
> int ret = zoo_aget(zkhandle, path,0,DataCompletion,” zoo_aget”);
>
> DataCompletion:
>
> DataCompletion(int rc, const char *value, int value_len, const struct Stat
> *stat, const void *data)
>
> {
>
>   Cout<<data<<endl;//out put is :zoo_aget
>
> }
>
>
>
> 2.But this is no right:
>
> Char* data = “zoo_aget”;
>
> int ret = zoo_aget(zkhandle, path,0,DataCompletion, data);
>
> DataCompletion:
>
> DataCompletion(int rc, const char *value, int value_len, const struct Stat
> *stat, const void *data)
>
> {
>
>   Cout<<data<<endl;//out put is not zoo_aget
>
> }
>
>
>
> Why I in 2 can not got correct output?Using zoo_axxx,pass data also the same
> question.
>
>
>
> Thanks,
>
>
>
> Albert Wu.
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB