Subject: Re: [PATCH] Support for exit-signal messages

Re: [PATCH] Support for exit-signal messages

From: Simon Josefsson <simon_at_josefsson.org>
Date: Tue, 05 Oct 2010 19:46:59 +0200

Daniel Stenberg <daniel_at_haxx.se> writes:

> On Tue, 5 Oct 2010, Simon Josefsson wrote:
>
>> Possibly libssh2 should have a 'libssh2_free' function.
>
> I think so, to be used when the default memory allocations are in use.

How about something like this?

/Simon

diff --git a/NEWS b/NEWS
index f706192..b907919 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+This release includes the following changes:
+
+ o Added libssh2_free()
+
 libssh2 1.2.7 (August 17, 2010)
 
 This release includes the following changes:
diff --git a/include/libssh2.h b/include/libssh2.h
index df065a0..ad7c51f 100644
--- a/include/libssh2.h
+++ b/include/libssh2.h
@@ -400,6 +400,13 @@ LIBSSH2_API int libssh2_init(int flags);
  */
 LIBSSH2_API void libssh2_exit(void);
 
+/*
+ * libssh2_free()
+ *
+ * Deallocate memory using the default memory allocator.
+ */
+LIBSSH2_API void libssh2_free(void *ptr)
+
 /* Session API */
 LIBSSH2_API LIBSSH2_SESSION *
 libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)),
diff --git a/src/misc.c b/src/misc.c
index e6c5e99..767c3cd 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1,5 +1,6 @@
 /* Copyright (c) 2004-2007 Sara Golemon <sarag_at_libssh2.org>
  * Copyright (c) 2009 by Daniel Stenberg
+ * Copyright (c) 2010 Simon Josefsson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms,
@@ -348,6 +349,12 @@ size_t _libssh2_base64_encode(LIBSSH2_SESSION *session,
 }
 /* ---- End of Base64 Encoding ---- */
 
+LIBSSH2_API void
+libssh2_free(void *ptr)
+{
+ free (ptr);
+}
+
 #ifdef LIBSSH2DEBUG
 LIBSSH2_API int
 libssh2_trace(LIBSSH2_SESSION * session, int bitmask)
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-10-05