int lssproto_InitServer(int (*writefunc)(int, char *, int), int worksiz) { int i; if((void *) writefunc == NULL) { lssproto.write_func = lssproto_default_write_wrap; } else { lssproto.write_func = writefunc; } lssproto_AllocateCommonWork(worksiz); lssproto_stringwrapper = (char **) calloc(1, sizeof(char *) * MAXLSRPCARGS); if(lssproto_stringwrapper == NULL) return -1; memset(lssproto_stringwrapper, 0, sizeof(char *) * MAXLSRPCARGS); for(i = 0; i < MAXLSRPCARGS; i++) { lssproto_stringwrapper[i] = (char *) calloc(1, worksiz); if(lssproto_stringwrapper[i] == NULL) { for(i = 0; i < MAXLSRPCARGS; i++) { free(lssproto_stringwrapper[i]); return -1; } } } lssproto.ret_work = (char *) calloc(1, sizeof(worksiz)); if(lssproto.ret_work == NULL) { return -1; } return 0; }
int lssproto_InitClient( int (*writefunc)(int,char*,int) ,int bufsiz ,int fd) { int i; if( (void*)writefunc == NULL){lssproto.write_func = lssproto_default_write_wrap;} else {lssproto.write_func = writefunc;} lssproto_AllocateCommonWork(bufsiz); lssproto_stringwrapper = (char**)malloc(sizeof(char*) * MAXLSRPCARGS); if(lssproto_stringwrapper ==NULL)return -1; lssproto_bzero( (char*)lssproto_stringwrapper , sizeof(char*)*MAXLSRPCARGS); for(i=0;i<MAXLSRPCARGS;i++){ lssproto_stringwrapper[i] = (char*)malloc( bufsiz ); if( lssproto_stringwrapper[i] == NULL){ for(i=0;i<MAXLSRPCARGS;i++){free( lssproto_stringwrapper[i]);return -1;} } } return 0; }