Explorar el Código

libdpkg: Refactor error_context creation into a new function

Guillem Jover hace 15 años
padre
commit
5dd05803b5
Se han modificado 1 ficheros con 17 adiciones y 7 borrados
  1. 17 7
      lib/dpkg/ehandle.c

+ 17 - 7
lib/dpkg/ehandle.c

@@ -99,9 +99,8 @@ run_error_handler(void)
   }
 }
 
-void
-push_error_handler(jmp_buf *jump, error_printer *printerror,
-                   const char *contextstring)
+static struct error_context *
+error_context_new(void)
 {
   struct error_context *necp;
 
@@ -116,12 +115,23 @@ push_error_handler(jmp_buf *jump, error_printer *printerror,
     fprintf(stderr, "%s: %s\n", thisname, errmsgbuf); exit(2);
   }
   necp->next= econtext;
-  necp->jump = jump;
   necp->cleanups= NULL;
-  necp->printerror= printerror;
-  necp->contextstring= contextstring;
   econtext= necp;
-  onerr_abort= 0;
+
+  return necp;
+}
+
+void
+push_error_handler(jmp_buf *jump, error_printer *printerror,
+                   const char *contextstring)
+{
+  struct error_context *ec;
+
+  ec = error_context_new();
+  ec->printerror = printerror;
+  ec->contextstring = contextstring;
+  ec->jump = jump;
+  onerr_abort = 0;
 }
 
 static void