You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Rick Yorgason <ri...@ldagames.com> on 2009/03/20 10:07:41 UTC

svn_client_status3 causing access violation; what am I doing wrong?

Hey everbody,

I'm trying to do something pretty simple with libsvn; just pass in the 
name of a file which is under source control, and retrieve the status. 
Unfortunately, my call to svn_client_status3 is just causing an access 
violation with no useful error status.  Any idea what I'm doing wrong?

Thanks; source follows.

-Rick-

#include <iostream>
#include <exception>

#include <svn_pools.h>
#include <svn_client.h>

using namespace std;

void statusFunc(void *baton, const char *path, svn_wc_status2_t *status)
{
	cout << "Test\n";
}

int main()
{
	apr_allocator_t *allocator;
	apr_pool_t* pPool;
	if(apr_allocator_create (&allocator))
		throw exception("Could not create top-level allocator.");

	apr_allocator_max_free_set (allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);

	pPool = svn_pool_create_ex (NULL, allocator);
	if(!pPool)
		throw exception("Could not create memory pool.");

	svn_client_ctx_t* ctx;
	svn_error_t* pError = svn_client_create_context(&ctx, pPool);
	if(pError)
		throw exception(pError->message);

	apr_pool_t* pSubpool = svn_pool_create(pPool);
	if(!pSubpool)
		throw exception("Could not create subpool.");

	svn_client_status3(NULL, 
"D:/Projects/hegemony.trunk/Release/Resources/Sounds/Ballista/Ballista_Creaks_Big_01.ogg", 
NULL, &statusFunc, NULL, svn_depth_infinity, true, false, true, false, 
NULL, ctx, pSubpool);

	return 0;
}

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1363389

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: svn_client_status3 causing access violation; what am I doing wrong?

Posted by Rick Yorgason <ri...@ldagames.com>.
Thanks, turns out all I needed to add was apr_initialize() and it worked 
perfectly.

Cheers,

-Rick-

Bert Huijben wrote:
> I think you miss some essential initializations of the APR and Subversion
> libraries.
> 
> You could look at
> http://svn.collab.net/repos/svn/trunk/tools/examples/minimal_client.c

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1368986

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

RE: svn_client_status3 causing access violation; what am I doing wrong?

Posted by Bert Huijben <rh...@sharpsvn.net>.
> -----Original Message-----
> From: Rick Yorgason [mailto:rick@ldagames.com]
> Sent: Friday, March 20, 2009 11:08 AM
> To: users@subversion.tigris.org
> Subject: svn_client_status3 causing access violation; what am I doing
> wrong?
> 
> Hey everbody,
> 
> I'm trying to do something pretty simple with libsvn; just pass in the
> name of a file which is under source control, and retrieve the status.
> Unfortunately, my call to svn_client_status3 is just causing an access
> violation with no useful error status.  Any idea what I'm doing wrong?

I think you miss some essential initializations of the APR and Subversion
libraries.

You could look at
http://svn.collab.net/repos/svn/trunk/tools/examples/minimal_client.c

to see what a minimal client could do to initialize the libraries properly.
(The example is somewhat outdated; you get a few deprecation warnings when
you use it on 1.6.0; but our compatibility guarantees promise that this
should work until 2.0)

In SharpSvn I use the following methods for global initialization:
apr_initialize()
svn_dso_initialize()
svn_utf_initialize()
svn_fs_initialize()

(SharpSvn doesn't initialize like a commandline tool, so I can't use
svn_cmdline_*()).


Thanks,
	Bert
> 
> Thanks; source follows.
> 
> -Rick-
> 
> #include <iostream>
> #include <exception>
> 
> #include <svn_pools.h>
> #include <svn_client.h>
> 
> using namespace std;
> 
> void statusFunc(void *baton, const char *path, svn_wc_status2_t
> *status)
> {
> 	cout << "Test\n";
> }
> 
> int main()
> {
> 	apr_allocator_t *allocator;
> 	apr_pool_t* pPool;
> 	if(apr_allocator_create (&allocator))
> 		throw exception("Could not create top-level allocator.");
> 
> 	apr_allocator_max_free_set (allocator,
> SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
> 
> 	pPool = svn_pool_create_ex (NULL, allocator);
> 	if(!pPool)
> 		throw exception("Could not create memory pool.");
> 
> 	svn_client_ctx_t* ctx;
> 	svn_error_t* pError = svn_client_create_context(&ctx, pPool);
> 	if(pError)
> 		throw exception(pError->message);
> 
> 	apr_pool_t* pSubpool = svn_pool_create(pPool);
> 	if(!pSubpool)
> 		throw exception("Could not create subpool.");
> 
> 	svn_client_status3(NULL,
> "D:/Projects/hegemony.trunk/Release/Resources/Sounds/Ballista/Ballista_
> Creaks_Big_01.ogg",
> NULL, &statusFunc, NULL, svn_depth_infinity, true, false, true, false,
> NULL, ctx, pSubpool);
> 
> 	return 0;
> }
> 
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessage
> Id=1363389
> 
> To unsubscribe from this discussion, e-mail: [users-
> unsubscribe@subversion.tigris.org].

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1366741

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].