[Opensrf-commits] r1205 - in trunk: include/opensrf src/libopensrf
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Jan 6 21:19:37 EST 2008
Author: miker
Date: 2008-01-06 20:55:25 -0500 (Sun, 06 Jan 2008)
New Revision: 1205
Modified:
trunk/include/opensrf/osrf_app_session.h
trunk/include/opensrf/osrf_list.h
trunk/include/opensrf/osrf_system.h
trunk/src/libopensrf/osrf_app_session.c
trunk/src/libopensrf/osrf_list.c
trunk/src/libopensrf/osrf_system.c
Log:
Two patch sets from Scott McKellar
First:
1. I moved the macros OSRF_LIST_DEFAULT_SIZE and OSRF_LIST_INC_SIZE
from the header into the implementation file. No other source files
reference them, nor should they.
2. I moved the OSRF_LIST_MAX_SIZE macro into the implementation file
as well, and then commented it out. It is nowhere referenced, but
out of caution I preserved it like a fly in amber.
3. I removed a leading underscore from each of the struct names
__osrfListStruct and __osrfListIteratorStruct.
4. I removed some obsolete comment text concerning osrfNewList().
5. I deleted the declaration for __osrfListSetSize(), which is
nowhere defined.
6. I made sure to explicitly initialize all struct members.
7. When allocating pointer arrays, I explicitly initialize all the
pointers to NULL.
8. I rewrote osrfNewList() as a thin wrapper for osrfNewListSize(),
to eliminate some duplication of code.
Second:
These patches eliminate the following identifiers, which have all been
replaced by their camel-case equivalents:
osrf_app_session_make_req
osrf_app_session_destroy
osrf_app_session_request_recv
osrf_app_request
osrf_system_get_transport_client
osrf_system_bootstrap_client_resc
Modified: trunk/include/opensrf/osrf_app_session.h
===================================================================
--- trunk/include/opensrf/osrf_app_session.h 2008-01-07 01:46:42 UTC (rev 1204)
+++ trunk/include/opensrf/osrf_app_session.h 2008-01-07 01:55:25 UTC (rev 1205)
@@ -39,7 +39,6 @@
timeout and set this variable back to false */
int reset_timeout;
};
-typedef struct osrf_app_request_struct osrf_app_request;
typedef struct osrf_app_request_struct osrfAppRequest;
struct osrf_app_session_struct {
@@ -116,10 +115,6 @@
osrfAppSession* session, const jsonObject* params,
const char* method_name, int protocol, string_array* param_strings);
-int osrf_app_session_make_req(
- osrfAppSession* session, const jsonObject* params,
- const char* method_name, int protocol, string_array* param_strings);
-
/** Sets the given request to complete state */
void osrf_app_session_set_complete( osrfAppSession* session, int request_id );
@@ -129,8 +124,6 @@
/** Does a recv call on the given request */
osrf_message* osrfAppSessionRequestRecv(
osrfAppSession* session, int request_id, int timeout );
-osrf_message* osrf_app_session_request_recv(
- osrfAppSession* session, int request_id, int timeout );
/** Removes the request from the request set and frees the reqest */
void osrf_app_session_request_finish( osrfAppSession* session, int request_id );
@@ -167,9 +160,8 @@
/** Disconnects (if client), frees any attached app_reuqests, removes the session from the
* global session cache and frees the session. Needless to say, only call this when the
- * session is completey done.
+ * session is completely done.
*/
-void osrf_app_session_destroy ( osrfAppSession* );
void osrfAppSessionFree( osrfAppSession* );
/* tells the request to reset it's wait timeout */
Modified: trunk/include/opensrf/osrf_list.h
===================================================================
--- trunk/include/opensrf/osrf_list.h 2008-01-07 01:46:42 UTC (rev 1204)
+++ trunk/include/opensrf/osrf_list.h 2008-01-07 01:55:25 UTC (rev 1205)
@@ -3,11 +3,6 @@
#include <opensrf/utils.h>
-#define OSRF_LIST_DEFAULT_SIZE 48 /* most opensrf lists are small... */
-#define OSRF_LIST_INC_SIZE 256
-#define OSRF_LIST_MAX_SIZE 10240
-
-
#define OSRF_LIST_GET_INDEX(l, i) (!l || i >= l->size) ? NULL: l->arrlist[i]
/**
@@ -16,20 +11,20 @@
then, it will be used on any item that needs to be freed, so don't mix data
types in the list if you want magic freeing */
-struct __osrfListStruct {
+struct _osrfListStruct {
unsigned int size; /* how many items in the list including NULL items between non-NULL items */
void (*freeItem) (void* item); /* callback for freeing stored items */
void** arrlist;
int arrsize; /* how big is the currently allocated array */
};
-typedef struct __osrfListStruct osrfList;
+typedef struct _osrfListStruct osrfList;
-struct __osrfListIteratorStruct {
+struct _osrfListIteratorStruct {
const osrfList* list;
unsigned int current;
};
-typedef struct __osrfListIteratorStruct osrfListIterator;
+typedef struct _osrfListIteratorStruct osrfListIterator;
osrfList* osrfNewListSize( unsigned int size );
@@ -55,9 +50,6 @@
/**
Allocates a new list
- @param compress If true, the list will compress empty slots on delete. If item positionality
- is not important, then using this feature is reccomended to keep the list from growing indefinitely.
- if item positionality is not important.
@return The allocated list
*/
osrfList* osrfNewList();
@@ -81,7 +73,7 @@
/**
Puts the given item into the list at the specified position. If there
- is already an item at the given position and the list has it's
+ is already an item at the given position and the list has its
"freeItem" function defined, then it will be used to free said item.
If no 'freeItem' callback is defined, then the displaced item will
be returned;
@@ -124,10 +116,6 @@
*/
int osrfListFind( const osrfList* list, void* addr );
-
-void __osrfListSetSize( osrfList* list );
-
-
/**
@return The number of non-null items in the list
*/
Modified: trunk/include/opensrf/osrf_system.h
===================================================================
--- trunk/include/opensrf/osrf_system.h 2008-01-07 01:46:42 UTC (rev 1204)
+++ trunk/include/opensrf/osrf_system.h 2008-01-07 01:55:25 UTC (rev 1205)
@@ -26,7 +26,6 @@
@return 1 on successs, 0 on failure.
*/
int osrfSystemBootstrapClientResc( char* configFile, char* contextNode, char* resource );
-int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, char* resource );
/**
Bootstrap the server.
@@ -39,7 +38,6 @@
int osrfSystemBootstrap( char* hostName, char* configfile, char* contextNode );
transport_client* osrfSystemGetTransportClient( void );
-transport_client* osrf_system_get_transport_client( void );
/* disconnects and destroys the current client connection */
int osrf_system_disconnect_client();
Modified: trunk/src/libopensrf/osrf_app_session.c
===================================================================
--- trunk/src/libopensrf/osrf_app_session.c 2008-01-07 01:46:42 UTC (rev 1204)
+++ trunk/src/libopensrf/osrf_app_session.c 2008-01-07 01:55:25 UTC (rev 1205)
@@ -374,14 +374,6 @@
method_name, protocol, param_strings, NULL );
}
-int osrf_app_session_make_req(
- osrfAppSession* session, const jsonObject* params,
- const char* method_name, int protocol, string_array* param_strings) {
-
- return osrfAppSessionMakeLocaleRequest(session, params,
- method_name, protocol, param_strings, NULL);
-}
-
static int osrfAppSessionMakeLocaleRequest(
osrfAppSession* session, const jsonObject* params, const char* method_name,
int protocol, string_array* param_strings, char* locale ) {
@@ -635,12 +627,7 @@
/** Disconnects (if client) and removes the given session from the global session cache
* ! This free's all attached app_requests !
*/
-void osrfAppSessionFree( osrfAppSession* ses ) {
- osrf_app_session_destroy( ses );
-}
-
-
-void osrf_app_session_destroy( osrfAppSession* session ){
+void osrfAppSessionFree( osrfAppSession* session ){
if(session == NULL) return;
osrfLogDebug(OSRF_LOG_MARK, "AppSession [%s] [%s] destroying self and deleting requests",
@@ -658,10 +645,6 @@
osrf_message* osrfAppSessionRequestRecv(
osrfAppSession* session, int req_id, int timeout ) {
- return osrf_app_session_request_recv( session, req_id, timeout );
-}
-osrf_message* osrf_app_session_request_recv(
- osrfAppSession* session, int req_id, int timeout ) {
if(req_id < 0 || session == NULL)
return NULL;
osrfAppRequest* req = OSRF_LIST_GET_INDEX( session->request_queue, req_id );
Modified: trunk/src/libopensrf/osrf_list.c
===================================================================
--- trunk/src/libopensrf/osrf_list.c 2008-01-07 01:46:42 UTC (rev 1204)
+++ trunk/src/libopensrf/osrf_list.c 2008-01-07 01:55:25 UTC (rev 1205)
@@ -1,19 +1,28 @@
#include <opensrf/osrf_list.h>
+#define OSRF_LIST_DEFAULT_SIZE 48 /* most opensrf lists are small... */
+#define OSRF_LIST_INC_SIZE 256
+//#define OSRF_LIST_MAX_SIZE 10240
+
osrfList* osrfNewList() {
- osrfList* list;
- OSRF_MALLOC(list, sizeof(osrfList));
- list->arrsize = OSRF_LIST_DEFAULT_SIZE;
- OSRF_MALLOC(list->arrlist, list->arrsize * sizeof(void*));
- return list;
+ return osrfNewListSize( OSRF_LIST_DEFAULT_SIZE );
}
osrfList* osrfNewListSize( unsigned int size ) {
osrfList* list;
OSRF_MALLOC(list, sizeof(osrfList));
+ list->size = 0;
+ list->freeItem = NULL;
if( size <= 0 ) size = 16;
list->arrsize = size;
OSRF_MALLOC( list->arrlist, list->arrsize * sizeof(void*) );
+
+ // Nullify all pointers in the array
+
+ int i;
+ for( i = 0; i < list->arrsize; ++i )
+ list->arrlist[ i ] = NULL;
+
return list;
}
@@ -36,17 +45,22 @@
void* osrfListSet( osrfList* list, void* item, unsigned int position ) {
if(!list || position < 0) return NULL;
- int i;
int newsize = list->arrsize;
- void** newarr;
while( position >= newsize )
newsize += OSRF_LIST_INC_SIZE;
if( newsize > list->arrsize ) { /* expand the list if necessary */
+ void** newarr;
OSRF_MALLOC(newarr, newsize * sizeof(void*));
- for( i = 0; i < list->arrsize; i++ )
+
+ // Copy the old pointers, and nullify the new ones
+
+ int i;
+ for( i = 0; i < list->arrsize; i++ )
newarr[i] = list->arrlist[i];
+ for( ; i < newsize; i++ )
+ newarr[i] = NULL;
free(list->arrlist);
list->arrlist = newarr;
list->arrsize = newsize;
Modified: trunk/src/libopensrf/osrf_system.c
===================================================================
--- trunk/src/libopensrf/osrf_system.c 2008-01-07 01:46:42 UTC (rev 1204)
+++ trunk/src/libopensrf/osrf_system.c 2008-01-07 01:55:25 UTC (rev 1205)
@@ -34,19 +34,10 @@
osrfGlobalTransportClient = NULL;
}
-transport_client* osrf_system_get_transport_client( void ) {
- return osrfGlobalTransportClient;
-}
-
int osrf_system_bootstrap_client( char* config_file, char* contextnode ) {
- return osrf_system_bootstrap_client_resc(config_file, contextnode, NULL);
+ return osrfSystemBootstrapClientResc(config_file, contextnode, NULL);
}
-int osrfSystemBootstrapClientResc( char* config_file, char* contextnode, char* resource ) {
- return osrf_system_bootstrap_client_resc( config_file, contextnode, resource );
-}
-
-
static int _osrfSystemInitCache( void ) {
jsonObject* cacheServers = osrf_settings_host_value_object("/cache/global/servers/server");
@@ -295,7 +286,7 @@
/*----------- End of routines to manage list of children --*/
-int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, char* resource ) {
+int osrfSystemBootstrapClientResc( char* config_file, char* contextnode, char* resource ) {
int failure = 0;
More information about the opensrf-commits
mailing list