$OpenBSD: patch-base_src_client_opencm_c,v 1.2 2003/05/28 13:27:48 todd Exp $
--- base/src/client/opencm.c.orig	Sun Apr  6 16:03:45 2003
+++ base/src/client/opencm.c	Wed May 28 08:14:56 2003
@@ -1252,6 +1252,7 @@ static void
 display_log(Repository *r, const CommitInfo *ci)
 {
   Mutable *m = NULL;
+  char *bVers;
 
   /* Get human readable name of current branch (if not cached) */
   if (!nmequal(CMGET(ci,branchURI), logBranchURI)) {
@@ -1267,9 +1268,11 @@ display_log(Repository *r, const CommitI
     modUserEmail = pubkey_GetEmail(modUser->pubKey);
   }
 
+  bVers = xunsigned64_str(CMGET(ci,branchVersion));
+
   /* Pretty print it */
-  report(0, "Branch version: %s (%s)\n", xunsigned64_str(CMGET(ci,branchVersion)),
-	  logBranchName); 
+  report(0, "Branch version: %s (%s)\n", bVers, logBranchName); 
+  free(bVers);
   report(0, "date: %s \nauthor: %s\n", CMGET(ci,time), modUserEmail);
   report(0, "%s\n", buffer_asString(CMGET(ci,descrip)));
   report(0, "----------------------------\n");
@@ -1455,8 +1458,9 @@ opencm_log(WorkSpace *ws, int argc, char
 
     const char *tmppath = NULL;
     const char *resolve_me = NULL;
-    const char *uri_prefix = path_join(ws->pc->branchURI, 
-				       xunsigned64_str(ws->pc->nRevisions - 1));
+    char *nRevs = xunsigned64_str(ws->pc->nRevisions - 1);
+    const char *uri_prefix = path_join(ws->pc->branchURI, nRevs);
+    free(nRevs);
 
     tmppath = ws_NormalizePath(ws, argv[0]);
 
@@ -2150,10 +2154,11 @@ opencm_logmail(WorkSpace *ws, int argc, 
           (CommitInfo *)repos_GetEntity(r, res->m->uri,
                                         CMGET(chg,commitInfoTrueName));
         User *u = (User *) client_GetMutableContent(r, CMGET(ci,authorURI));
+	char *bVers = xunsigned64_str(CMGET(ci,branchVersion));
 
         fprintf(f, "Project: %s\n", res->m->name);
-        fprintf(f, "New version: %s/%s\n", CMGET(ci,branchURI), 
-                xunsigned64_str(CMGET(ci,branchVersion)));
+        fprintf(f, "New version: %s/%s\n", CMGET(ci,branchURI), bVers);
+	free(bVers);
 
         fprintf(f, "Author: %s\n", pubkey_GetEmail(u->pubKey));
         fprintf(f, "Time: %s\n", CMGET(ci,time));
@@ -2384,14 +2389,17 @@ markfn(Repository *r, const char *tn, vo
     /* It's a mutable */
     Mutable *m = repos_GetMutable(r, tn);
     unsigned long long revno;
+    char *nRevs = xunsigned64_str(m->nRevisions);
 
-    report(0, "[%06d] %s has %s revisions\n", ms->depth, tn, 
-	    xunsigned64_str(m->nRevisions));
+    report(0, "[%06d] %s has %s revisions\n", ms->depth, tn, nRevs);
+    free(nRevs);
 
 #if 1
     for (revno = 0; revno < m->nRevisions; revno++) {
       Revision *rev = repos_GetRevision(r, tn, revno);
-      report(0, "[%06d] revision %s \n", ms->depth+1, xunsigned64_str(revno));
+      nRevs = xunsigned64_str(revno);
+      report(0, "[%06d] revision %s \n", ms->depth+1, nRevs);
+      free(nRevs);
       ms->depth += 2;
       ser_mark(r, rev, markfn, state);
       ms->depth -= 2;
@@ -2400,7 +2408,9 @@ markfn(Repository *r, const char *tn, vo
     revno = m->nRevisions -1;
     for(;;) {
       Revision *rev = repos_GetRevision(r, tn, revno);
-      report(0, "[%06ds]revision %s \n", ms->depth+1, xunsigned64_str(revno));
+      nRevs = xunsigned64_str(revno);
+      report(0, "[%06ds]revision %s \n", ms->depth+1, nRevs);
+      free(nRevs);
       ms->depth += 2;
       ser_mark(r, rev, markfn, state);
       ms->depth -= 2;
@@ -2447,10 +2457,10 @@ mark_addmark(const void *container, stru
     report(2, "Add M %s -> %s\n", ((const Mutable *)container)->uri, tn);
   }
   else if (GETTYPE(container) == TY_Revision) {
+    char *seq = xunsigned64_str( ((const Revision *)container)->seq_number );
     report(2, "Add R %s/%s -> %s\n", 
-	    ((const Revision *)container)->mutURI, 
-	    xunsigned64_str( ((const Revision *)container)->seq_number ), 
-	    tn);
+	    ((const Revision *)container)->mutURI, seq, tn );
+    free(seq);
   }
   else {
     static const void *last_container = 0;
@@ -2511,7 +2521,7 @@ mark_add_count(rbtree *mark_counts, Seri
   rbn = rbtree_find(mark_counts, &lookupKey);
 
   if (rbn == TREE_NIL) {
-    unsigned *data = GC_MALLOC_ATOMIC(sizeof(unsigned));
+    unsigned *data = calloc(1, sizeof(unsigned));
     *data = 0;
 
     rbn = rbnode_create(lookupKey.vp, lookupKey.w, data);
@@ -2582,6 +2592,7 @@ opencm_mark(WorkSpace *ws, int argc, cha
     while ((nd = rbtree_root(marks)) != TREE_NIL) {
       rbkey lookupKey;
       const char *tn = nd->value.vp;
+      char *xstr;
 
       assert (tn != 0);
 
@@ -2593,7 +2604,9 @@ opencm_mark(WorkSpace *ws, int argc, cha
       if (rbtree_find(visited, &lookupKey) != TREE_NIL)
 	continue;
 
-      report(1, "Mark %s %s\n", xunsigned64_str(count), tn);
+      xstr = xunsigned64_str(count);
+      report(1, "Mark %s %s\n", xstr, tn);
+      free(xstr);
       count++;
 
       rbtree_insert(visited, rbnode_create(tn, 0, 0));
@@ -2620,8 +2633,9 @@ opencm_mark(WorkSpace *ws, int argc, cha
 	  ser_mark(r, m, m, newMarks);
 	  mark_add_count(mark_counts, (Serializable *) m);
 
-	  report(1, "Mark mutable %s (%s revisions)\n", tn,
-                 xunsigned64_str(m->nRevisions));
+	  xstr = xunsigned64_str(m->nRevisions);
+	  report(1, "Mark mutable %s (%s revisions)\n", tn, xstr);
+	  free(xstr);
 
 	  for (revno = 0; revno < m->nRevisions; revno++) {
 	    Revision *rev = 0;
@@ -2633,7 +2647,9 @@ opencm_mark(WorkSpace *ws, int argc, cha
 	    } END_CATCH;
 
 	    if (rev) {
-	      report(1, "revision %s/%s \n", tn, xunsigned64_str(revno));
+	      xstr = xunsigned64_str(revno);
+	      report(1, "revision %s/%s \n", tn, xstr);
+	      free(xstr);
 	      ser_mark(r, rev, rev, newMarks);
 	      mark_add_count(mark_counts, (Serializable *) rev);
 	    }
@@ -2728,7 +2744,7 @@ typedef struct config_files {
 static config_files *
 find_config_files(OC_bool needThem)
 {
-  config_files *cfg = GC_MALLOC(sizeof(*cfg));
+  config_files *cfg = calloc(1, sizeof(*cfg));
 
   const char *user_dir = path_join(opt_ConfigDir, CM_USER_SUBDIR);
 
@@ -2820,48 +2836,16 @@ process_environment()
     opt_user = CM_DEFAULT_USER;
 }
 
-static void* ssl_malloc(size_t howmuch)
-{
-  return GC_MALLOC(howmuch);
-}
-
-static void* ssl_realloc(void* ptr, size_t size)
-{
-  return GC_REALLOC(ptr, size);
-}
-
-static void ssl_free(void* ptr)
-{
-#if 1
-   /* do nothing; let the GC handle it */
-#else
-  GC_FREE(ptr);
-#endif
-}
-
 int
 main(int argc, char *argv[])
 {
   int dummy;
   struct found_command fc;
-  WorkSpace *ws = 0;
+  WorkSpace *ws = NULL;
 
   /* Set up the initial logging rules immediately */
   log_set_verbosity(0);
 
-  GC_expand_hp (8 * 1024 * 1024);
-  /* GC_use_entire_heap = 1; */
-  /* GC_enable_incremental(); */
-
-  /*
-     OpenSSL has some leaks (and it looks like we hit them pretty hard at
-     times). But by having it use the GC instead of the standard libc
-     malloc/realloc/free, we can prevent the worst of it.
-  */
-#if USE_SSL_GC
-  CRYPTO_set_mem_functions(ssl_malloc, ssl_realloc, ssl_free);
-#endif
-
   appInvokedName = argv[0];
   appName = CM_APPNAME;
 
@@ -2904,7 +2888,7 @@ main(int argc, char *argv[])
 	  ! CMD_ISFLAG(fc.cmd, (CF_ADMIN)))
 	ws = ws_Init(fc.cmd, 0);
 
-      this_repos = 0;
+      this_repos = NULL;
 
       if (! CMD_ISFLAG(fc.cmd, CF_NOCONNECT)) {
 	/* We will need the config files unless (a) there is no
@@ -3056,7 +3040,7 @@ pendingchange_addNote(PendingChange *pc,
     unsigned msg_len = strlen(msg);
 
     /* add 3 for intervening LF, trailing LF,trailing NUL */
-    s = GC_MALLOC_ATOMIC(notes_len + msg_len + 3);
+    s = calloc(1, notes_len + msg_len + 3);
     if (pc->notes) {
       strcpy(s, pc->notes);
       s[notes_len++] = '\n';
