Some readability improvements in HashedSetAbstractDomain

Summary: Removed a number of template instantiations that the compiler is able to deduce, so as to improve readability.

Differential Revision: D4889665

fbshipit-source-id: 8d84372c77649914f83acbae6381e5602580e02a

--- libredex/HashedSetAbstractDomain.h
+++ libredex/HashedSetAbstractDomain.h
@@ -44,7 +44,7 @@

   Kind kind() const override { return Kind::Value; }

-  bool leq(const SetValue<Element, Hash, Equal>& other) const override {
+  bool leq(const SetValue& other) const override {
     if (m_set.size() > other.m_set.size()) {
       return false;
     }
@@ -56,22 +56,20 @@
     return true;
   }

-  bool equals(const SetValue<Element, Hash, Equal>& other) const override {
+  bool equals(const SetValue& other) const override {
     return (m_set.size() == other.m_set.size()) && leq(other);
   }

-  Kind join_with(const SetValue<Element, Hash, Equal>& other) override {
+  Kind join_with(const SetValue& other) override {
     for (const Element& e : other.m_set) {
       m_set.insert(e);
     }
     return Kind::Value;
   }

-  Kind widen_with(const SetValue<Element, Hash, Equal>& other) override {
-    return join_with(other);
-  }
-
-  Kind meet_with(const SetValue<Element, Hash, Equal>& other) override {
+  Kind widen_with(const SetValue& other) override { return join_with(other); }
+
+  Kind meet_with(const SetValue& other) override {
     for (auto it = m_set.begin(); it != m_set.end();) {
       if (other.m_set.count(*it) == 0) {
         it = m_set.erase(it);
@@ -82,9 +80,7 @@
     return Kind::Value;
   }

-  Kind narrow_with(const SetValue<Element, Hash, Equal>& other) override {
-    return meet_with(other);
-  }
+  Kind narrow_with(const SetValue& other) override { return meet_with(other); }

  private:
   std::unordered_set<Element, Hash, Equal> m_set;


TCXB7-3627 : Toggling wifi radio settings leading to pod disconnection

Reason for change: Restart mesh when radio toggles.
Test Procedure: Check pod is online after toggling wifi radio
   dmcli eRT setv Device.WiFi.Radio.2.X_CISCO_COM_ApplySetting bool true
   dmcli eRT setv Device.WiFi.Radio.1.X_CISCO_COM_ApplySetting bool true

Risks: Low

Signed-off-by: Mohammed Arif Mannoppilly Hassan <2299f77cc7de57d949b7f315734e869297910349@comcast.com>
Change-Id: Ib5a1ab99da82da8091a49dcb7cbf5a0ea7cd5864


Initial

Initial

--- problems/linux/exceptionHandling.c
+++ problems/linux/exceptionHandling.c
@@ -1,6 +1,3 @@
-// Copyright (c) 2015 Arista Networks, Inc.  All rights reserved.
-// Arista Networks, Inc. Confidential and Proprietary.
-
 #include <unistd.h>
 #include <setjmp.h>
 #include <signal.h>


Fix OOB indexing, buffer check, realloc size

error: pathspec 'C/Input.h' did not match any file(s) known to git

--- C/Input.h
+++ C/Input.h
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+char* Input(char *buffer){
+    unsigned int size = 10;
+    unsigned int len = 0;
+    int ch;
+
+    buffer = malloc(sizeof(char)*size);
+    if(!buffer){
+        printf("Error allocating memory");
+        return buffer;
+    }
+    while((ch = fgetc(stdin)) != EOF && ch != '\n'){
+        buffer[len] = ch;
+        if(len == size-1){
+            size = size << 4;
+            buffer = realloc(buffer,sizeof(char)*size);
+            if(!buffer){
+                printf("Error reallocating memory");
+                return buffer;
+            }
+        }
+        len++;
+    }
+    buffer[len] = '\0';
+    buffer = realloc(buffer,sizeof(buffer));
+    return buffer;
+}


Add includes to fix user-compilation of acpica.  Also clarify a comment about overriding the OS name.

--- sys/contrib/dev/acpica/acfreebsd.h
+++ sys/contrib/dev/acpica/acfreebsd.h
@@ -118,8 +118,9 @@
 #define __ACFREEBSD_H__

 /*
- * XXX this is technically correct, but will cause problems with some ASL
- *     which only works if the string names a Microsoft operating system.
+ * Some systems' ASL may have problems because they look for names
+ * of Microsoft operating systems.  To override this, set hw.acpi.os_name
+ * to the appropriate string.
  */
 #define ACPI_OS_NAME                "FreeBSD"

@@ -159,6 +160,9 @@

 /* Not building kernel code, so use libc */
 #define ACPI_USE_STANDARD_HEADERS
+#define ACPI_FLUSH_CPU_CACHE()
+#include <sys/types.h>
+#include <ctype.h>

 #define __cli()
 #define __sti()


thermometer: Store Intermediate Temperature CCC handle in struct

This patch adds Intermediate Measurement CCC handle value directly into
thermometer struct. This way there's no need to traverse nested lists
looking for value.

write_ccc() function and related helpers are now unused so can be
removed.

--- profiles/thermometer/thermometer.c
+++ profiles/thermometer/thermometer.c
@@ -82,6 +82,7 @@
 	gboolean			has_interval;

 	uint16_t			measurement_ccc_handle;
+	uint16_t			intermediate_ccc_handle;
 };

 struct characteristic {
@@ -255,14 +256,6 @@
 	return ch->attr.value_handle - *handle;
 }

-static gint cmp_descriptor(gconstpointer a, gconstpointer b)
-{
-	const struct descriptor *desc = a;
-	const bt_uuid_t *uuid = b;
-
-	return bt_uuid_cmp(&desc->uuid, uuid);
-}
-
 static struct thermometer_adapter *
 find_thermometer_adapter(struct btd_adapter *adapter)
 {
@@ -280,18 +273,6 @@
 	GSList *l;

 	l = g_slist_find_custom(t->chars, uuid, cmp_char_uuid);
-	if (l == NULL)
-		return NULL;
-
-	return l->data;
-}
-
-static struct descriptor *get_descriptor(struct characteristic *ch,
-							const bt_uuid_t *uuid)
-{
-	GSList *l;
-
-	l = g_slist_find_custom(ch->desc, uuid, cmp_descriptor);
 	if (l == NULL)
 		return NULL;

@@ -415,6 +396,8 @@
 								"indication");
 		} else if (g_strcmp0(ch->attr.uuid,
 					INTERMEDIATE_TEMPERATURE_UUID) == 0) {
+			desc->ch->t->intermediate_ccc_handle = desc->handle;
+
 			if (g_slist_length(ch->t->tadapter->iwatchers) == 0)
 				return;

@@ -728,38 +711,6 @@
 	return write_attr_interval(t, msg, value);
 }

-static void write_ccc(struct thermometer *t, const char *uuid, uint16_t value)
-{
-	struct characteristic *ch;
-	struct descriptor *desc;
-	bt_uuid_t btuuid;
-	uint8_t atval[2];
-	char *msg;
-
-	if (t->attrib == NULL)
-		return;
-
-	ch = get_characteristic(t, uuid);
-	if (ch == NULL) {
-		DBG("Characteristic %s not found", uuid);
-		return;
-	}
-
-	bt_uuid16_create(&btuuid, GATT_CLIENT_CHARAC_CFG_UUID);
-	desc = get_descriptor(ch, &btuuid);
-	if (desc == NULL) {
-		DBG("CCC descriptor for %s not found", uuid);
-		return;
-	}
-
-	att_put_u16(value, atval);
-
-	msg = g_strdup_printf("Write CCC: %04x for %s", value, uuid);
-
-	gatt_write_char(t->attrib, desc->handle, atval, sizeof(atval),
-							write_ccc_cb, msg);
-}
-
 static void enable_final_measurement(gpointer data, gpointer user_data)
 {
 	struct thermometer *t = data;
@@ -780,9 +731,18 @@
 static void enable_intermediate_measurement(gpointer data, gpointer user_data)
 {
 	struct thermometer *t = data;
-
-	write_ccc(t, INTERMEDIATE_TEMPERATURE_UUID,
-					GATT_CLIENT_CHARAC_CFG_NOTIF_BIT);
+	uint16_t handle = t->intermediate_ccc_handle;
+	uint8_t value[2];
+	char *msg;
+
+	if (t->attrib == NULL || !handle)
+		return;
+
+	att_put_u16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);
+	msg = g_strdup("Enable Intermediate Temperature notifications");
+
+	gatt_write_char(t->attrib, handle, value, sizeof(value),
+							write_ccc_cb, msg);
 }

 static void disable_final_measurement(gpointer data, gpointer user_data)
@@ -805,8 +765,18 @@
 static void disable_intermediate_measurement(gpointer data, gpointer user_data)
 {
 	struct thermometer *t = data;
-
-	write_ccc(t, INTERMEDIATE_TEMPERATURE_UUID, 0x0000);
+	uint16_t handle = t->intermediate_ccc_handle;
+	uint8_t value[2];
+	char *msg;
+
+	if (t->attrib == NULL || !handle)
+		return;
+
+	att_put_u16(0x0000, value);
+	msg = g_strdup("Disable Intermediate Temperature notifications");
+
+	gatt_write_char(t->attrib, handle, value, sizeof(value),
+							write_ccc_cb, msg);
 }

 static void remove_int_watcher(struct thermometer_adapter *tadapter,


GIBS-1098 - Issue with non-daily date snapping

Tested:
single and multi-year periods
monthly and multi-monthly periods and those larger than a year
All tests done w/ leap and standard years

--- src/mod_onearth/mod_onearth.c
+++ src/mod_onearth/mod_onearth.c
@@ -322,6 +322,7 @@
 			  int interval = 0;
 			  int start_offset = 0;
 			  int start_leap = 0;
+			  int start_year = 0;
 			  int i;
 			  for (i=0;i<num_periods;i++) {
 				  ap_log_error(APLOG_MARK,APLOG_WARNING,0,r->server,"Evaluating time period %s", time_period);
@@ -338,6 +339,7 @@
 				  // check to see if there is a start time before the request time
 				  if (strlen(time_period)>=10) {
 					  st.tm_year=apr_atoi64(time_period);
+					  start_year=st.tm_year;
 					  if (tm.tm_year >= st.tm_year) {
 						  time_period+=5;
 						  st.tm_mon=apr_atoi64(time_period);
@@ -390,21 +392,80 @@
 					  // calculate the last date in the span of the time interval
 					  int span = start_offset % interval;
 					  int request_day = tm.tm_yday;
-					  if (start_offset <= interval && start_offset >= 0) {
-						  request_day = st.tm_yday;
+					  // Evaluate monthly period
+					  if (time_period[(strlen(time_period)-1)] == 'M') {
+					  	  st.tm_yday = start_leap ? st.tm_yday-1 : st.tm_yday;
+					  	  // Get closest month to request date
+					  	  int month_count = 13-st.tm_mon + (12*(tm.tm_year-st.tm_year-1)) + tm.tm_mon;
+					  	  int i;
+					  	  for(i=1; i<month_count; i+=interval) {
+					  	  	st.tm_mon += interval;
+					  	  	if(st.tm_mon > 12) {
+					  	  		st.tm_year+=(st.tm_mon/12);
+					  	  		st.tm_mon = st.tm_mon % 12;
+					  	  	}
+					  	  }
+					  	  // Step back to get the previous interval if this one is ahead of the req date
+					  	  if (st.tm_year > tm.tm_year || (st.tm_mon > tm.tm_mon || (st.tm_mon == tm.tm_mon && st.tm_mday > tm.tm_mday))) {
+					  	  	// Month subtraction routine
+					  	  	while(interval!=0) {
+					  	  		st.tm_mon--;
+					  	  		if (st.tm_mon==0)
+					  	  		{
+					  	  			st.tm_mon=12;
+					  	  			st.tm_year--;
+					  	  		}
+					  	  		interval--;
+					  	  	}
+					  	  }
+					  	  // Using APR time functions to get yday (converting date struct to epoch and back gets us accurate yday)
+					  	  // Zero out any info we don't need (otherwise messes up the epoch/time struct conversion)
+					  	  st.tm_yday = 0;
+					  	  st.tm_hour = 0;
+					  	  st.tm_min = 0;
+					  	  st.tm_gmtoff = 0;
+						  // Normally tm_mon is zero-indexed
+					  	  st.tm_mon--;
+					  	  // Date to epoch and then back
+					  	  apr_time_t start_epoch;
+					  	  apr_time_exp_get(&start_epoch, &st);
+					  	  apr_time_exp_gmt(&st, start_epoch);
+					  	  // tm_yday and tm_mon comes out zero-indexed, set it back
+					  	  st.tm_yday++;
+					  	  st.tm_mon++;
+					  	  request_day = st.tm_yday;
+				  	  // Evaluate yearly period
+					  } else if (time_period[(strlen(time_period)-1)] == 'Y') {
+					  	  int year_interval = apr_atoi64(time_period+6);
+					  	  // Strip off the extra day that's added if the start was a leap year
+					  	  st.tm_yday = start_leap ? st.tm_yday-1 : st.tm_yday;
+					  	  // Count up years to get the closest interval to requested date
+					  	  while ( start_year < tm.tm_year ) {
+					  	  	start_year += year_interval;
+					  	  }
+					  	  // Go back one interval if this date is later than the requested one
+					  	  if(start_year > tm.tm_year || (st.tm_mon > tm.tm_mon || (st.tm_mon == tm.tm_mon && st.tm_mday > tm.tm_mday))) {
+					  	  	start_year -= year_interval;
+					  	  }
+					  	  // Add a yday if the snapped date is a leap year
+					  	  st.tm_year = start_year;
+				  	  	  leap = (st.tm_year%4)?0:((st.tm_year%400)?((st.tm_year%100)?1:0):1);
+				  	  	  st.tm_yday = leap ? st.tm_yday+1 : st.tm_yday;
+				  	  	  request_day = st.tm_yday;
 					  } else {
-						  // check if month period
-						  if (time_period[(strlen(time_period)-1)] == 'M') {
-							  tm.tm_mday = st.tm_mday;
-							  span = request_day; // store old value
-							  request_day=tm.tm_mday+moffset[tm.tm_mon-interval]+((tm.tm_mon>2)?leap:0);
-							  span = span-request_day+1; // get actual span
-						  } else {
-//							  ap_log_error(APLOG_MARK,APLOG_WARNING,0,r->server,"%d [request day] - (%d [days since start] %% %d [period interval]) = %d [date]", request_day, start_offset, interval, (request_day-span));
-							  request_day = request_day - span;
-						  }
+						  request_day = request_day - span;
 					  }
-					  char old_char=*(fnloc+7);
+					  char old_char;
+					  // Correct year name in path if it's changed
+					  if (st.tm_year!=tm.tm_year) {
+					  	old_char=*(yearloc+4);
+					  	sprintf(yearloc, "%04d", st.tm_year);
+					  	*(yearloc+4)=old_char;
+					  }
+					  // Change request date to the date we're snapping to
+					  tm = st;
+					  // Assemble filename
+					  old_char=*(fnloc+7);
 					  sprintf(fnloc,"%04d%03d",tm.tm_year,request_day);
 					  *(fnloc+7)=old_char;
 				  } else { // subdaily request


Removed maximum time restriction on timerNext_ms

--- CANopen.c
+++ CANopen.c
@@ -835,12 +835,6 @@
         CO_NMT_blinkingProcess50ms(co->NMT);
     }
 #endif /* CO_USE_LEDS */
-    if(timerNext_ms != NULL){
-        if(*timerNext_ms > 50){
-            *timerNext_ms = 50;
-        }
-    }
-

     for(i=0; i<CO_NO_SDO_SERVER; i++){
         CO_SDO_process(


and now disable this hide handling. no longer needed with no-hide hack.

SVN revision: 50762

--- src/modules/comp/e_mod_comp.c
+++ src/modules/comp/e_mod_comp.c
@@ -1722,6 +1722,7 @@
         // fixme: ask the x homies. why does this need to be done?
         // why free pixmap (+texture bound), undriect, then redirect again
         // getting pixmap againand well - getting texture too again. why?
+#if 0 // disable
         if (cw->redirected)
           {
              if (cw->pixmap) ecore_x_pixmap_free(cw->pixmap);
@@ -1766,6 +1767,7 @@
              cw->dmg_updates = 0;
              ecore_x_e_comp_pixmap_set(cw->win, cw->pixmap);
           }
+#endif
         if (_comp_mod->conf->send_flush)
           {
              if (cw->bd) ecore_x_e_comp_flush_send(cw->bd->client.win);


CmdLineParser::Option::operator== fixed. Now only uses the names for comparison.

git-svn-id: 285d6e11b92f44d073a8e12a14e649675b16fc71@523 3ec011a9-ccf5-4689-8f2f-5f4aa021d377

--- sys/include/vislib/CmdLineParser.h
+++ sys/include/vislib/CmdLineParser.h
@@ -769,7 +769,8 @@
             }

             /**
-             * Compare operator.
+             * Compare operator. This is purely based on the short and the
+             * long name of the option.
              *
              * @param rhs The right hand side operand
              *
@@ -777,8 +778,7 @@
              */
             inline bool operator==(const Option& rhs) const {
                 return (this->shortName == rhs.shortName)
-                    && (this->longName == rhs.longName)
-                    && (this->valueType == rhs.valueType);
+                    && (this->longName == rhs.longName);
             }

         private:


If we must yell at the user than a file cannot be linked into place when requested (not required) to do it, reassure them that cpio is still intelligent enough that it will perform a full copy instead.

--- contrib/cpio/copypass.c
+++ contrib/cpio/copypass.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
 /* copypass.c - cpio copy pass sub-function.
    Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.

@@ -468,7 +469,7 @@
     }
   else if (link_flag)
     {
-      error (0, errno, "cannot link %s to %s",
+      error (0, errno, "cannot link %s to %s (will copy instead)",
 	     link_target, link_name);
     }
 #endif /* not __MSDOS__ */


updated contextual in example/demo

updated contextual in example/demo

--- example/demo/demo.c
+++ example/demo/demo.c
@@ -228,7 +228,6 @@
     static int toggle0 = 1;
     static int toggle1 = 0;
     static int toggle2 = 1;
-    int clicked = 0;

     ctx->style.font.height = 20;
     zr_begin(ctx, &layout, "Button Demo", zr_rect(50,50,255,610),
@@ -314,8 +313,7 @@
     /*------------------------------------------------
      *                  CONTEXTUAL
      *------------------------------------------------*/
-    clicked = zr_input_mouse_clicked(&ctx->input, ZR_BUTTON_RIGHT, zr_window_get_bounds(ctx));
-    if (zr_contextual_begin(ctx, &menu, ZR_WINDOW_NO_SCROLLBAR, zr_vec2(120, 200), clicked)) {
+    if (zr_contextual_begin(ctx, &menu, ZR_WINDOW_NO_SCROLLBAR, zr_vec2(120, 200), zr_window_get_bounds(ctx))) {
         ctx->style.font.height = 18;
         zr_layout_row_dynamic(ctx, 25, 1);
         if (zr_contextual_item_icon(ctx, zr_image_id(img->copy), "Clone", ZR_TEXT_RIGHT))


e17/comp: use input winodw for cm_selection. still not working with gksu overlay somehow..

SVN revision: 57801

--- src/modules/comp/e_mod_comp.c
+++ src/modules/comp/e_mod_comp.c
@@ -44,7 +44,8 @@
    int             frameskip;

    E_Manager_Comp  comp;
-
+   Ecore_X_Window  cm_selection;
+
    Eina_Bool       gl : 1;
    Eina_Bool       grabbed : 1;
    Eina_Bool       nocomp : 1;
@@ -2861,8 +2862,15 @@
      }

    /* FIXME check if already composited? */
-   ecore_x_screen_is_composited_set(man->num, c->win);
-
+   c->cm_selection = ecore_x_window_input_new(man->root, 0, 0, 1, 1);
+   if (!c->cm_selection)
+     {
+	ecore_x_composite_render_window_disable(c->win);
+	free(c);
+	return NULL;
+     }
+   ecore_x_screen_is_composited_set(c->man->num, c->cm_selection);
+
    if (c->man->num == 0) e_alert_composite_win = c->win;

    if (_comp_mod->conf->engine == E_EVAS_ENGINE_GL_X11)
@@ -3029,6 +3037,8 @@
    if (c->update_job) ecore_job_del(c->update_job);
    if (c->wins_list) eina_list_free(c->wins_list);

+   ecore_x_window_free(c->cm_selection);
+   ecore_x_screen_is_composited_set(c->man->num, 0);
    ecore_x_e_comp_sync_supported_set(c->man->root, 0);

    free(c);


Operate on a fully in-memory DB for more speed

Unfortunately, still far too slow as the number of rows increases.

--- rdiffdb.c
+++ rdiffdb.c
@@ -45,22 +45,31 @@

    const char *db_path = argv[1];

-   sqlite3 *db;
-   int err = sqlite3_open(db_path, &db);
+   sqlite3 *diskdb;
+   int err = sqlite3_open(db_path, &diskdb);
    if (err) {
       fprintf(stderr, "Error opening DB at '%s': %s\n",
               db_path, sqlite3_errstr(err));
       return 3;
    }

+   sqlite3 *db;
+   err = sqlite3_open(":memory:", &db);
+   if (err)
+      return fail_sql("creating in-memory DB", sqlite3_errstr(err));
+
+   sqlite3_backup *bak = sqlite3_backup_init(db, "main", diskdb, "main");
+   if (!bak)
+      return fail_sql("initing DB load", sqlite3_errmsg(db));
+
+   err = sqlite3_backup_step(bak, -1);
+   if (err != SQLITE_DONE)
+      return fail_sql("loading DB to memory", sqlite3_errmsg(db));
+
+   sqlite3_backup_finish(bak);
+
    char *errmsg;
-   sqlite3_exec(db, "PRAGMA journal_mode = MEMORY", NULL, NULL, &errmsg);
-   if (errmsg) return fail_sql("setting pragma", errmsg);
-   sqlite3_exec(db, "PRAGMA synchronous = OFF", NULL, NULL, &errmsg);
-   if (errmsg) return fail_sql("setting pragma", errmsg);
    sqlite3_exec(db, "PRAGMA encoding = \"UTF-8\"", NULL, NULL, &errmsg);
-   if (errmsg) return fail_sql("setting pragma", errmsg);
-   sqlite3_exec(db, "PRAGMA temp_store = MEMORY", NULL, NULL, &errmsg);
    if (errmsg) return fail_sql("setting pragma", errmsg);

    sqlite3_exec(
@@ -182,6 +191,14 @@

    sqlite3_exec(db, "COMMIT", NULL, NULL, &errmsg);
    if (errmsg) return fail_sql("committing", errmsg);
+
+   bak = sqlite3_backup_init(diskdb, "main", db, "main");
+   if (!bak)
+      return fail_sql("initing DB save", sqlite3_errmsg(db));
+
+   err = sqlite3_backup_step(bak, -1);
+   if (err != SQLITE_DONE)
+      return fail_sql("saving DB to disk", sqlite4_errmsg(db));
 }

 static int go(


[OVAL] quiet gcc

[OVAL] quiet gcc

--- src/OVAL/oval_probe_ext.c
+++ src/OVAL/oval_probe_ext.c
@@ -762,11 +762,10 @@
         switch(act) {
         case PROBE_HANDLER_ACT_EVAL:
         {
-                struct oval_object   *obj;
                 struct oval_sysinfo **inf;
                 /* int flags = va_arg(ap, int); */

-                obj = va_arg(ap, struct oval_object *);
+                va_arg(ap, struct oval_object *);
                 inf = va_arg(ap, struct oval_sysinfo **);
                 pd  = oval_pdtbl_get(pext->pdtbl, type);

@@ -1117,9 +1116,7 @@

 int oval_probe_ext_reset(SEAP_CTX_t *ctx, oval_pd_t *pd, oval_pext_t *pext)
 {
-        void *res;
-
-        res = SEAP_cmd_exec(ctx, pd->sd, SEAP_EXEC_RECV, PROBECMD_RESET, NULL, SEAP_CMDTYPE_SYNC, NULL, NULL);
+        SEAP_cmd_exec(ctx, pd->sd, SEAP_EXEC_RECV, PROBECMD_RESET, NULL, SEAP_CMDTYPE_SYNC, NULL, NULL);

         return (0);
 }


nua_register.c: refreshing REGISTER uses now method from dialog_usage_class.

darcs-hash:20060817134801-65a35-1ec729474d565b5db9b2a731c9f24639ebdbe643.gz

--- libsofia-sip-ua/nua/nua_register.c
+++ libsofia-sip-ua/nua/nua_register.c
@@ -110,6 +110,9 @@
 static void nua_register_usage_peer_info(nua_dialog_usage_t *du,
 					 nua_dialog_state_t const *ds,
 					 sip_t const *sip);
+static void nua_register_usage_refresh(nua_handle_t *, nua_dialog_usage_t *,
+				       sip_time_t);
+static int nua_register_usage_shutdown(nua_handle_t *, nua_dialog_usage_t *);

 /** REGISTER usage, aka nua_registration_t */
 struct register_usage {
@@ -154,6 +157,8 @@
     nua_register_usage_remove,
     nua_register_usage_name,
     nua_register_usage_peer_info,
+    nua_register_usage_refresh,
+    nua_register_usage_shutdown
   }};

 static char const *nua_register_usage_name(nua_dialog_usage_t const *du)
@@ -214,7 +219,6 @@
 /* REGISTER */

 static void restart_register(nua_handle_t *nh, tagi_t *tags);
-static void refresh_register(nua_handle_t *, nua_dialog_usage_t *, sip_time_t);

 static int process_response_to_register(nua_handle_t *nh,
 					nta_outgoing_t *orq,
@@ -583,30 +587,26 @@
     msg_destroy(msg);
 }

-void
-refresh_register(nua_handle_t *nh, nua_dialog_usage_t *du, sip_time_t now)
+/** Refresh registration */
+static
+void nua_register_usage_refresh(nua_handle_t *nh,
+				nua_dialog_usage_t *du,
+				sip_time_t now)
 {
   nua_t *nua = nh->nh_nua;
   nua_client_request_t *cr = nh->nh_cr;
   nua_registration_t *nr = nua_dialog_usage_private(du);
-  nua_event_t e;
   msg_t *msg;
   sip_t *sip;
-  int terminating;
+
+  if (du->du_terminating || du->du_shutdown)
+    return;

   if (cr->cr_msg) {
-    /* Delay of 5 .. 15 seconds */
+    /* Busy, delay of 5 .. 15 seconds */
     nua_dialog_usage_set_refresh(du, 5 + (unsigned)random() % 11U);
-    du->du_pending = refresh_register;
     return;
   }
-
-  if (now > 0)
-    e = nua_r_register;
-  else
-    e = nua_r_destroy, du->du_terminating = 1;
-
-  terminating = du->du_terminating;

   outbound_stop_keepalive(nr->nr_ob);

@@ -619,33 +619,84 @@
   if (!msg || !sip)
     goto error;

-  if (terminating)
-    unregister_expires_contacts(msg, sip);
-
   cr->cr_orq =
-    outbound_register_request(nr->nr_ob, terminating,
+    outbound_register_request(nr->nr_ob, 0,
 			      nr->nr_by_stack ? nr->nr_contact : NULL,
 			      nh->nh_nua->nua_nta,
 			      process_response_to_register, nh, NULL,
 			      msg,
 			      SIPTAG_END(),
-			      TAG_IF(terminating, NTATAG_SIGCOMP_CLOSE(1)),
-			      TAG_IF(!terminating, NTATAG_COMP("sigcomp")),
+			      NTATAG_COMP("sigcomp"),
 			      TAG_END());
   if (!cr->cr_orq)
     goto error;

   cr->cr_usage = du;
-  cr->cr_event = e;
+  cr->cr_event = nua_r_register;
   return;

  error:
-  if (terminating)
-    nua_dialog_usage_remove(nh, nh->nh_ds, du);
   msg_destroy(msg);
   msg_destroy(cr->cr_msg);
-  UA_EVENT2(e, NUA_INTERNAL_ERROR, TAG_END());
+  UA_EVENT2(nua_r_register, NUA_INTERNAL_ERROR, TAG_END());
   return;
+}
+
+/** Shutdown register usage.
+ *
+ * Called when stack is shut down or handle is destroyed. Unregister.
+ */
+static
+int nua_register_usage_shutdown(nua_handle_t *nh, nua_dialog_usage_t *du)
+{
+  nua_t *nua = nh->nh_nua;
+  nua_client_request_t *cr = nh->nh_cr;
+  nua_registration_t *nr = nua_dialog_usage_private(du);
+  msg_t *msg;
+  sip_t *sip;
+
+  if (du->du_terminating)	/* Already terminating? */
+    return 100;
+
+  du->du_terminating = 1;
+
+  if (cr->cr_msg)    /* Busy */
+    return 100;
+
+  outbound_stop_keepalive(nr->nr_ob);
+
+  cr->cr_msg = msg_copy(du->du_msg);
+  msg = nua_creq_msg(nua, nh, cr, 1,
+		     SIP_METHOD_REGISTER,
+		     NUTAG_USE_DIALOG(1),
+		     TAG_END());
+  sip = sip_object(msg);
+  if (!msg || !sip)
+    goto error;
+
+  unregister_expires_contacts(msg, sip);
+
+  cr->cr_orq =
+    outbound_register_request(nr->nr_ob, 1,
+			      nr->nr_by_stack ? nr->nr_contact : NULL,
+			      nh->nh_nua->nua_nta,
+			      process_response_to_register, nh, NULL,
+			      msg,
+			      SIPTAG_END(),
+			      NTATAG_SIGCOMP_CLOSE(1),
+			      TAG_END());
+  if (!cr->cr_orq)
+    goto error;
+
+  cr->cr_usage = du;
+  cr->cr_event = nua_r_destroy;
+  return 200;
+
+ error:
+  nua_dialog_usage_remove(nh, nh->nh_ds, du);
+  msg_destroy(msg);
+  msg_destroy(cr->cr_msg);
+  return 500;
 }

@@ -749,8 +800,6 @@
     }

     nua_dialog_usage_set_refresh(du, mindelta);
-    if (mindelta)
-      du->du_pending = refresh_register;
   }

 #if HAVE_SIGCOMP


Remove duplicate PQclear(res) operations leading to double free() and subsequent core dump.  It looks like at one time DBLINK_RES_ERROR_AS_NOTICE didn't include a PQclear, but now it does and so these other ones are duplicate.

--- contrib/dblink/dblink.c
+++ contrib/dblink/dblink.c
@@ -345,7 +345,6 @@
 		else
 		{
 			DBLINK_RES_ERROR_AS_NOTICE("sql error");
-			PQclear(res);
 			PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
 		}
 	}
@@ -419,7 +418,6 @@
 		else
 		{
 			DBLINK_RES_ERROR_AS_NOTICE("sql error");
-			PQclear(res);
 			PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
 		}
 	}
@@ -531,8 +529,6 @@
 				DBLINK_RES_ERROR("sql error");
 			else
 			{
-				if (res)
-					PQclear(res);
 				DBLINK_RES_ERROR_AS_NOTICE("sql error");
 				SRF_RETURN_DONE(funcctx);
 			}
@@ -720,11 +716,9 @@
 				DBLINK_RES_ERROR("sql error");
 			else
 			{
-				if (res)
-					PQclear(res);
+				DBLINK_RES_ERROR_AS_NOTICE("sql error");
 				if (freeconn)
 					PQfinish(conn);
-				DBLINK_RES_ERROR_AS_NOTICE("sql error");
 				SRF_RETURN_DONE(funcctx);
 			}
 		}
@@ -938,13 +932,15 @@
 		 * result tuple
 		 */
 		sql_cmd_status = GET_TEXT(PQcmdStatus(res));
+		PQclear(res);
 	}
 	else
+	{
+		PQclear(res);
 		ereport(ERROR,
 			  (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
 			   errmsg("statement returning results not allowed")));
-
-	PQclear(res);
+	}

 	/* if needed, close the connection to the database and cleanup */
 	if (freeconn)


E Comp (wayland): Fix a few more instances of
ecore_x_composite_name_window_pixmap_get when building w/ wayland
client support.

git-svn-id: 6ac5796aeae0cef97fb47bcc287d4ce899c6fa6e@67556 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/modules/comp/e_mod_comp.c
+++ src/modules/comp/e_mod_comp.c
@@ -598,6 +598,9 @@
    if ((cw->c->gl) && (_comp_mod->conf->texture_from_pixmap) &&
        (!cw->shaped) && (!cw->rects))
      {
+#ifdef HAVE_WAYLAND
+        DBG("DEBUG - pm now %x\n", e_mod_comp_wl_pixmap_get(cw->win));
+#endif
         DBG("DEBUG - pm now %x\n", ecore_x_composite_name_window_pixmap_get(cw->win));
         evas_object_image_size_set(cw->obj, cw->pw, cw->ph);
         EINA_LIST_FOREACH(cw->obj_mirror, l, o)
@@ -1114,7 +1117,12 @@
                        printf("^^^^ redirect2 %x\n", cw->win);
                        printf("  redr\n");
                        ecore_x_composite_redirect_window(cw->win, ECORE_X_COMPOSITE_UPDATE_MANUAL);
-                       cw->pixmap = ecore_x_composite_name_window_pixmap_get(cw->win);
+
+#ifdef HAVE_WAYLAND
+                       cw->pixmap = e_mod_comp_wl_pixmap_get(cw->win);
+#endif
+                       if (!cw->pixmap)
+                         cw->pixmap = ecore_x_composite_name_window_pixmap_get(cw->win);
                        if (cw->pixmap)
                          {
                             ecore_x_pixmap_geometry_get(cw->pixmap, NULL, NULL, &(cw->pw), &(cw->ph));
@@ -2052,38 +2060,42 @@
      cw->dmg_updates = 1;
    if ((!cw->redirected) || (!cw->pixmap))
      {
-// we redirect all subwindows anyway
-//        ecore_x_composite_redirect_window(cw->win, ECORE_X_COMPOSITE_UPDATE_MANUAL);
-              cw->pixmap = ecore_x_composite_name_window_pixmap_get(cw->win);
-              if (cw->pixmap)
-                {
-                   ecore_x_pixmap_geometry_get(cw->pixmap, NULL, NULL, &(cw->pw), &(cw->ph));
-                   _e_mod_comp_win_ready_timeout_setup(cw);
-                }
-              else
-                {
-                   cw->pw = 0;
-                   cw->ph = 0;
-                }
-              if ((cw->pw <= 0) || (cw->ph <= 0))
-                {
-                   if (cw->pixmap)
-                     {
-                        ecore_x_pixmap_free(cw->pixmap);
-                        cw->pixmap = 0;
-                     }
-//             cw->show_ready = 0; // hmm maybe not needed?
-                }
-              cw->redirected = 1;
-              DBG("  [0x%x] up resize %ix%i\n", cw->win, cw->pw, cw->ph);
-              e_mod_comp_update_resize(cw->up, cw->pw, cw->ph);
-              e_mod_comp_update_add(cw->up, 0, 0, cw->pw, cw->ph);
-              evas_object_image_size_set(cw->obj, cw->pw, cw->ph);
-              EINA_LIST_FOREACH(cw->obj_mirror, l, o)
-                {
-                   evas_object_image_size_set(o, cw->pw, cw->ph);
-                }
-              ecore_x_e_comp_pixmap_set(cw->win, cw->pixmap);
+        // we redirect all subwindows anyway
+        //        ecore_x_composite_redirect_window(cw->win, ECORE_X_COMPOSITE_UPDATE_MANUAL);
+#ifdef HAVE_WAYLAND
+        cw->pixmap = e_mod_comp_wl_pixmap_get(cw->win);
+#endif
+        if (!cw->pixmap)
+          cw->pixmap = ecore_x_composite_name_window_pixmap_get(cw->win);
+        if (cw->pixmap)
+          {
+             ecore_x_pixmap_geometry_get(cw->pixmap, NULL, NULL, &(cw->pw), &(cw->ph));
+             _e_mod_comp_win_ready_timeout_setup(cw);
+          }
+        else
+          {
+             cw->pw = 0;
+             cw->ph = 0;
+          }
+        if ((cw->pw <= 0) || (cw->ph <= 0))
+          {
+             if (cw->pixmap)
+               {
+                  ecore_x_pixmap_free(cw->pixmap);
+                  cw->pixmap = 0;
+               }
+             //             cw->show_ready = 0; // hmm maybe not needed?
+          }
+        cw->redirected = 1;
+        DBG("  [0x%x] up resize %ix%i\n", cw->win, cw->pw, cw->ph);
+        e_mod_comp_update_resize(cw->up, cw->pw, cw->ph);
+        e_mod_comp_update_add(cw->up, 0, 0, cw->pw, cw->ph);
+        evas_object_image_size_set(cw->obj, cw->pw, cw->ph);
+        EINA_LIST_FOREACH(cw->obj_mirror, l, o)
+          {
+             evas_object_image_size_set(o, cw->pw, cw->ph);
+          }
+        ecore_x_e_comp_pixmap_set(cw->win, cw->pixmap);
      }
    if ((cw->dmg_updates >= 1) && (cw->show_ready))
      {


An interrupt should also occur when using external clock.

--- Core/gb.c
+++ Core/gb.c
@@ -530,6 +530,7 @@
         return;
     }
     gb->io_registers[GB_IO_SB] = data;
+    gb->io_registers[GB_IO_IF] |= 8;
 }

 void GB_set_sample_rate(GB_gameboy_t *gb, unsigned int sample_rate)


datman: reduce task priority

datman: reduce task priority

--- src/modules/dataman/dataman.c
+++ src/modules/dataman/dataman.c
@@ -797,7 +797,7 @@
 	sem_init(&g_init_sema, 1, 0);

 	/* start the worker thread */
-	if ((task = task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, 2000, task_main, NULL)) <= 0) {
+	if ((task = task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT, 2000, task_main, NULL)) <= 0) {
 		warn("task start failed");
 		return -1;
 	}


• added to the CustomQuery class the multipleLineEditingButton IBOutlet

--- Source/CustomQuery.h
+++ Source/CustomQuery.h
@@ -51,6 +51,7 @@
 	IBOutlet id copyQueryFavoriteButton;
 	IBOutlet id runSelectionButton;
 	IBOutlet id runAllButton;
+	IBOutlet id multipleLineEditingButton;

 	IBOutlet NSMenuItem *runSelectionMenuItem;
 	IBOutlet NSMenuItem *clearHistoryMenuItem;


Sorry C++ users

Sorry C++ users

--- Core/gb.h
+++ Core/gb.h
@@ -3,6 +3,7 @@
 #define typeof __typeof__
 #include <stdbool.h>
 #include <stdint.h>
+#include <stdalign.h>
 #include <time.h>

 #include "defs.h"
@@ -782,7 +783,7 @@

 #ifndef GB_INTERNAL
 struct GB_gameboy_s {
-    _Alignas(struct GB_gameboy_internal_s) uint8_t __internal[sizeof(struct GB_gameboy_internal_s)];
+    alignas(struct GB_gameboy_internal_s) uint8_t __internal[sizeof(struct GB_gameboy_internal_s)];
 };
 #endif


Use builtin call context instead of posix state


e ibar/ibox fix starrting/started signal emittion

i found this didn't emit signals correctly and multiple times when not
needed. this fixes that.

@fix

--- src/modules/ibar/e_mod_main.c
+++ src/modules/ibar/e_mod_main.c
@@ -90,6 +90,7 @@
    Eina_Bool       focused : 1;
    Eina_Bool       not_in_order : 1;
    Eina_Bool       menu_grabbed : 1;
+   Eina_Bool       starting : 1;
 };

 static IBar        *_ibar_new(Evas_Object *parent, Instance *inst);
@@ -1736,7 +1737,8 @@
    switch (type)
      {
       case E_EXEC_WATCH_STARTED:
-        _ibar_icon_signal_emit(ic, "e,state,started", "e");
+        if (ic->starting) _ibar_icon_signal_emit(ic, "e,state,started", "e");
+        ic->starting = EINA_FALSE;
         if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,on", "e");
         if (ic->exe_inst == inst) ic->exe_inst = NULL;
         if (!eina_list_data_find(ic->exes, inst))
@@ -1789,7 +1791,8 @@
                {
                   ic->exe_inst = einst;
                   e_exec_instance_watcher_add(einst, _ibar_instance_watch, ic);
-                  _ibar_icon_signal_emit(ic, "e,state,starting", "e");
+                  if (!ic->starting) _ibar_icon_signal_emit(ic, "e,state,starting", "e");
+                  ic->starting = EINA_TRUE;
                }
           }
      }
@@ -2606,7 +2609,8 @@
           {
              if (ic)
                {
-                  _ibar_icon_signal_emit(ic, "e,state,started", "e");
+                  if (ic->starting) _ibar_icon_signal_emit(ic, "e,state,started", "e");
+                  ic->starting = EINA_FALSE;
                   if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,on", "e");
                   if (!eina_list_data_find(ic->exes, ev->ec->exe_inst))
                     ic->exes = eina_list_append(ic->exes, ev->ec->exe_inst);
@@ -2655,7 +2659,8 @@
         ic = eina_hash_find(b->icon_hash, _desktop_name_get(exe->desktop));
         if (ic)
           {
-             _ibar_icon_signal_emit(ic, "e,state,started", "e");
+             if (ic->starting) _ibar_icon_signal_emit(ic, "e,state,started", "e");
+             ic->starting = EINA_FALSE;
              ic->exes = eina_list_remove(ic->exes, exe);
              if (ic->exe_inst == exe) ic->exe_inst = NULL;
              if (!ic->exes)
@@ -2696,7 +2701,8 @@
         ic = eina_hash_find(b->icon_hash, _desktop_name_get(exe->desktop));
         if (ic)
           {
-             _ibar_icon_signal_emit(ic, "e,state,started", "e");
+             if (ic->starting) _ibar_icon_signal_emit(ic, "e,state,started", "e");
+             ic->starting = EINA_FALSE;
              if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,on", "e");
              if (skip) continue;
              if (!eina_list_data_find(ic->exes, exe))
@@ -2742,7 +2748,6 @@
         ic = eina_hash_find(b->icon_hash, _desktop_name_get(exe->desktop));
         if (ic)
           {
-             _ibar_icon_signal_emit(ic, "e,state,started", "e");
              if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,on", "e");
              if (skip) continue;
              if (!eina_list_data_find(ic->exes, exe))


Small Glulx impl

Small Glulx impl

--- Source/Glulx/State.h
+++ Source/Glulx/State.h
@@ -40,12 +40,18 @@
       const Header* header = story.getHeader();

       memory.resize(header->end_mem);
+      stack.reserve(header->stack_size);
    }

+   //! Return whether the machine should stop
+   bool isQuitRequested() const { return quit; }
+
+   //! Reset the dynamic state to the initial conditions.
    void reset()
    {
       const Header* header = story.getHeader();

+      quit      = false;
       pc        = header->start_func;
       frame_ptr = 0;

@@ -56,7 +62,11 @@
    }

 private:
+   // Static configuration
    const Story&         story;
+
+   // Dynamic state
+   bool                 quit{false};
    uint32_t             pc{0};
    uint32_t             frame_ptr{0};
    std::vector<uint8_t> memory;


fix bug where GetTimeout() is 0 then min resolution always wins

--- Csocket.h
+++ Csocket.h
@@ -28,7 +28,7 @@
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
-* $Revision: 1.175 $
+* $Revision: 1.176 $
 */

 // note to compile with win32 need to link to winsock2, using gcc its -lws2_32
@@ -2132,8 +2132,9 @@
 					iTimeoutInSeconds = 0;
 				else
 					iTimeoutInSeconds -= iDiff;
+
+				iMinTimeout = std::min( iMinTimeout, iTimeoutInSeconds );
 			}
-			iMinTimeout = std::min( iMinTimeout, iTimeoutInSeconds );

 			const std::vector<CCron *> & vCrons = (*this)[a]->GetCrons();
 			for( u_long b = 0; b < vCrons.size(); b++ )


Remove printf

Remove printf

--- src/modules/ibar/e_mod_main.c
+++ src/modules/ibar/e_mod_main.c
@@ -923,7 +923,6 @@
      {
 	d1 = bx;
 	d2 = ww - (bx + bw);
-	printf("d1: %d, d2: %d\n", d1, d2);
 	if (bw > 0)
 	  {
 	     if (d1 < d2)


add cron deletion access

add cron deletion access

--- Csocket.h
+++ Csocket.h
@@ -28,7 +28,7 @@
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
-* $Revision: 1.90 $
+* $Revision: 1.91 $
 */

 #ifndef _HAS_CSOCKET_
@@ -1524,6 +1524,46 @@
 		virtual void AddCron( CCron * pcCron )
 		{
 			m_vcCrons.push_back( pcCron );
+		}
+
+		//! delete cron(s) by name
+		virtual void DelCron( const CS_STRING & sName, bool bDeleteAll = true, bool bCaseSensitive = true )
+		{
+			for( u_int a = 0; a < m_vcCrons.size(); a++ )
+			{
+				if ( ( bCaseSensitive ?
+							( m_vcCrons[a]->GetName().compare( sName ) == 0 ) : ( m_vcCrons[a]->GetName().casecompare( sName ) == 0 ) ) )
+				{
+					m_vcCrons[a]->Stop();
+					CS_Delete( m_vcCrons[a] );
+					m_vcCrons.erase( m_vcCrons.begin() + a-- );
+				}
+			}
+		}
+
+		//! delete cron by idx
+		virtual void DelCron( u_int iPos )
+		{
+			if ( iPos < m_vcCrons.size() )
+			{
+				m_vcCrons[iPos]->Stop();
+				CS_Delete( m_vcCrons[iPos] );
+				m_vcCrons.erase( m_vcCrons.begin() + iPos );
+			}
+		}
+		//! delete cron by address
+		virtual void DelCronByAddr( CCron *pcCron )
+		{
+			for( u_int a = 0; a < m_vcCrons.size(); a++ )
+			{
+				if ( m_vcCrons[a] == pcCron )
+				{
+					m_vcCrons[a]->Stop();
+					CS_Delete( m_vcCrons[a] );
+					m_vcCrons.erase( m_vcCrons.begin() + a );
+					return;
+				}
+			}
 		}

 		/**
@@ -2107,6 +2147,46 @@
 			m_vcCrons.push_back( pcCron );
 		}

+		//! delete cron(s) by name
+		virtual void DelCron( const CS_STRING & sName, bool bDeleteAll = true, bool bCaseSensitive = true )
+		{
+			for( u_int a = 0; a < m_vcCrons.size(); a++ )
+			{
+				if ( ( bCaseSensitive ?
+							( m_vcCrons[a]->GetName().compare( sName ) == 0 ) : ( m_vcCrons[a]->GetName().casecompare( sName ) == 0 ) ) )
+				{
+					m_vcCrons[a]->Stop();
+					CS_Delete( m_vcCrons[a] );
+					m_vcCrons.erase( m_vcCrons.begin() + a-- );
+				}
+			}
+		}
+
+		//! delete cron by idx
+		virtual void DelCron( u_int iPos )
+		{
+			if ( iPos < m_vcCrons.size() )
+			{
+				m_vcCrons[iPos]->Stop();
+				CS_Delete( m_vcCrons[iPos] );
+				m_vcCrons.erase( m_vcCrons.begin() + iPos );
+			}
+		}
+		//! delete cron by address
+		virtual void DelCronByAddr( CCron *pcCron )
+		{
+			for( u_int a = 0; a < m_vcCrons.size(); a++ )
+			{
+				if ( m_vcCrons[a] == pcCron )
+				{
+					m_vcCrons[a]->Stop();
+					CS_Delete( m_vcCrons[a] );
+					m_vcCrons.erase( m_vcCrons.begin() + a );
+					return;
+				}
+			}
+		}
+
 		//! Get the Select Timeout in MILLISECONDS
 		u_int GetSelectTimeout() { return( m_iSelectWait ); }
 		//! Set the Select Timeout in MILLISECONDS


Removed the FIXME: Icon preferences comment.

SVN revision: 23105

--- src/modules/ibox/e_mod_main.c
+++ src/modules/ibox/e_mod_main.c
@@ -542,7 +542,6 @@
    evas_object_pass_events_set(ic->o_icon2, 1);
    evas_object_show(ic->o_icon2);

-   /* FIXME: preferences for icon name */
    switch (ic->ibox->icon_label)
      {
       case 0:


udp - number of packet

udp - number of packet

--- tcp_template/ftp_udp_server/main.c
+++ tcp_template/ftp_udp_server/main.c
@@ -9,6 +9,7 @@
 int pull(int sock, struct sockaddr * cli_addr, char * file, int clilen); //взять файл с сервера
 int push(int sock, struct sockaddr * cli_addr, char * path, int clilen); //положить файл на сервер
 int readn(int sockfd, struct sockaddr * cli_addr, char *buf, int n, int clilen);
+int checkRec (char * mes, int counter);

 int parse (int sock, struct sockaddr * cli_addr, char * message, int clilen) {
     char command [6]; // храним команду
@@ -40,11 +41,11 @@
 int direxist(int sock, struct sockaddr * cli_addr, char *  path, int clilen) {
     DIR* dir;
     if ((dir = opendir(path)) == NULL) {
-        char n[1] = "n";
-        sendto(sock, &n[0], 1, 0, cli_addr, clilen); // папки не существует, клиент не изменит адрес
+        char n[3] = "01n";
+        sendto(sock, &n[0], 3, 0, cli_addr, clilen); // папки не существует, клиент не изменит адрес
     } else {
-        char y[1] = "y";
-        sendto(sock, &y[0], 1, 0, cli_addr, clilen); // клиент получит одобрение на изменение адреса
+        char y[3] = "01y";
+        sendto(sock, &y[0], 3, 0, cli_addr, clilen); // клиент получит одобрение на изменение адреса
     }
     closedir(dir);
     return 1;
@@ -54,14 +55,17 @@
     DIR* dir;
     struct dirent* de;
     char ans [256];
+    int recCounter = 2;
+    int sendCounter = 2;
     memset(ans, 0, 256);
     if ((dir = opendir(path)) == NULL) {
-        char n[1] = "n";
-        sendto(sock, &n[0], 1, 0, cli_addr, clilen); // если папки не существует
+        char n[3] = "01n";
+        sendto(sock, &n[0], 3, 0, cli_addr, clilen); // если папки не существует
     } else {
-        char y[1] = "y";
-        sendto(sock, &y[0], 1, 0, cli_addr, clilen);
-    }
+        char y[3] = "01y";
+        sendto(sock, &y[0], 3, 0, cli_addr, clilen);
+    }
+    Sleep(1);
     // в цикле перебираем все содержимое, отправляя новое сообщения для каждого файла
     while ((de = readdir(dir)) != NULL) {
         memset(ans, 0, 256);
@@ -72,29 +76,41 @@
                 ans[i + 1] = ans[i];
             ans[0] = '/';
         }
+        for (int i = 256; i > 1; i--) {
+            ans[i] = ans[i-2];
+        }
+        ans[0] = (int)(sendCounter / 10) + '0';
+        ans[1] = sendCounter % 10 + '0';
         sendto(sock, &ans[0], 256, 0, cli_addr, clilen);
-    }
-    char lsEnd[256] = "_ls_end";
+        sendCounter++;
+    }
+    char lsEnd[256];
+    memset(lsEnd, 0, 256);
+    lsEnd[0] = (int)(sendCounter / 10) + '0';
+    lsEnd[1] = sendCounter % 10 + '0';
+    strcat(lsEnd, "_ls_end");
     sendto(sock, &lsEnd[0], 256, 0, cli_addr, clilen); // по данной строке клиент закончит прием сообщений
     closedir(dir);
     return 1;
 }

 int pull(int sock, struct sockaddr * cli_addr, char * file, int clilen) {
-    char temp [3];
+    char temp [5];
+    int recCounter = 2;
+    int sendCounter = 2;
     // *передача клиенту указанного файла от сервера*
     // проверка, есть ли этот файл
     FILE * fp;
     if((fp = fopen(file, "rb")) == NULL) {
         // если нет, то сервер отправляет отказ. клиент не начинает прием
-        char n[1] = "n";
-        sendto(sock, &n[0], 1, 0, cli_addr, clilen); //  отказ
+        char n[3] = "01n";
+        sendto(sock, &n[0], 3, 0, cli_addr, clilen); //  отказ
         return 0;
     }
     // если да, то сервер отправляет подтверждение и начинает передачу, которую закончит спец строкой
     // подтверждение
-    char y[1] = "y";
-    sendto(sock, &y[0], 1, 0, cli_addr, clilen);
+    char y[3] = "01y";
+    sendto(sock, &y[0], 3, 0, cli_addr, clilen);
     // оправляем файл
     int size = 0;
     char sendbuff[256];
@@ -110,41 +126,66 @@
         }
         memset(temp, 0, 3);
         int temp2;
-        temp[2] = ((int)(size % 10) + '0');
+        temp[0] = (int)(sendCounter / 10) + '0';
+        temp[1] = sendCounter % 10 + '0';
+        temp[4] = ((int)(size % 10) + '0');
         temp2 = size / 10;
-        temp[1] = ((int)(temp2 % 10) + '0');
-        temp[0] = ((int)(temp2 / 10) + '0');
-        sendto(sock, &temp[0], 3, 0, cli_addr, clilen);
-        sendto(sock, &sendbuff[0], size, 0, cli_addr, clilen);
-    }
-    char str256[3] = "256";
-    sendto(sock, &str256[0], 3, 0, cli_addr, clilen);
-    char endFile[256] = "_end_of_file";
+        temp[3] = ((int)(temp2 % 10) + '0');
+        temp[2] = ((int)(temp2 / 10) + '0');
+        sendto(sock, &temp[0], 5, 0, cli_addr, clilen);
+        sendCounter++;
+        for (int i = 256; i > 1; i--) {
+            sendbuff[i] = sendbuff[i-2];
+        }
+        sendbuff[0] = (int)(sendCounter / 10) + '0';
+        sendbuff[1] = sendCounter % 10 + '0';
+        sendto(sock, &sendbuff[0], size+2, 0, cli_addr, clilen);
+        sendCounter++;
+    }
+    char str256[5];
+    memset(str256, 0, 5);
+    str256[0] = (int)(sendCounter / 10) + '0';
+    str256[1] = sendCounter % 10 + '0';
+    strcat(str256, "256");
+    sendto(sock, &str256[0], 5, 0, cli_addr, clilen);
+    sendCounter++;
+    char endFile[256];
+    memset(endFile, 0, 256);
+    endFile[0] = (int)(sendCounter / 10) + '0';
+    endFile[1] = sendCounter % 10 + '0';
+    strcat(endFile, "_end_of_file");
     sendto(sock, &endFile[0], 256, 0, cli_addr, clilen);
+    sendCounter++;
     fclose(fp);
     return 1;
 }

 int push(int sock, struct sockaddr * cli_addr, char * path, int clilen) {
     int size;
+    int recCounter = 2;
+    int sendCounter = 2;
     // *прием сервером файла от клиента*
     // попытка открыть файл по адресу
     FILE * fp;
     if((fp = fopen(path, "wb")) == NULL) {
         // если нет, то отослать отказ. клиент не начинает передачу
-        char n[1] = "n";
-        sendto(sock, &n[0], 1, 0, cli_addr, clilen);
+        char n[3] = "01n";
+        sendto(sock, &n[0], 3, 0, cli_addr, clilen);
         return 0;
     }
     // если да, то отослать подтверждение, и начать прием файла. конец приема по спец строке
-    char y[1] = "y";
-    sendto(sock, &y[0], 1, 0, cli_addr, clilen);
+    char y[3] = "01y";
+    sendto(sock, &y[0], 3, 0, cli_addr, clilen);
     char buffer [256];
     memset(buffer, 0, 256);
-    recvfrom(sock, buffer, 3, 0, cli_addr, &clilen);
+    recvfrom(sock, buffer, 5, 0, cli_addr, &clilen);
+    if (checkRec(buffer, recCounter)) return 0;
+    recCounter++;
     size = atoi(buffer);
     memset(buffer, 0, 256);
-    recvfrom(sock, buffer, size, 0, cli_addr, &clilen);
+    recvfrom(sock, buffer, size+2, 0, cli_addr, &clilen);
+    if (checkRec(buffer, recCounter)) return 0;
+    recCounter++;
     while (strncmp(buffer, "_end_of_file", 256)) {
         if (!(strncmp(buffer, "/_end_of_file", 256))) {
             int i;
@@ -154,10 +195,15 @@
         fwrite((void *) buffer, sizeof(char), size, fp);
         fflush(fp);
         memset(buffer, 0, 256);
-        recvfrom(sock, buffer, 3, 0, cli_addr, &clilen);
+        recvfrom(sock, buffer, 5, 0, cli_addr, &clilen);
+        if (checkRec(buffer, recCounter)) return 0;
+        recCounter++;
         size = atoi(buffer);
+        if (size > 254) size = 254;
         memset(buffer, 0, 256);
-        recvfrom(sock, buffer, size, 0, cli_addr, &clilen);
+        recvfrom(sock, buffer, size+2, 0, cli_addr, &clilen);
+        if (checkRec(buffer, recCounter)) return 0;
+        recCounter++;
     }
     fclose(fp);
     return 1;
@@ -185,14 +231,16 @@
     while(1) {
         memset(buf, 0, 256);
         //int n = readn(sock, cli_addr, p, 3, clilen);
-        int n = recvfrom(sock, buf, 3, 0, cli_addr, &clilen);
+        int n = recvfrom(sock, buf, 5, 0, cli_addr, &clilen);
+        if (checkRec(buf, 0)) return 3;
         if (n < 0) {
             perror("ERROR on reading");
             exit(1);
         }
         int length = atoi(p);
         memset(buf, 0, 256);
-        n = recvfrom(sock, buf, length, 0, cli_addr, &clilen);
+        n = recvfrom(sock, buf, length+2, 0, cli_addr, &clilen);
+        if (checkRec(buf, 1)) return 3;
         if (n < 0) {
             perror("ERROR on reading");
             exit(1);
@@ -208,6 +256,19 @@
     }
     shutdown(sock, 2);
     closesocket(sock);
+    return 1;
+}
+
+int checkRec (char * mes, int counter) {
+    char temp[2];
+    temp[0] = mes[0];
+    temp[1] = mes[1];
+    for (int i = 0; i < 254; i++) {
+        mes[i] = mes[i+2];
+    }
+    int co = atoi(temp);
+    if (co == counter + 1) return 0;
+    printf("Ошибка приема - неверный порядок пакетов\n");
     return 1;
 }

@@ -255,7 +316,10 @@
     //Sleep (5000);

     clilen = sizeof(cli_addr);
-    readAndWrite(sockfd, (struct sockaddr *)&cli_addr, clilen);
+    int check = readAndWrite(sockfd, (struct sockaddr *)&cli_addr, clilen);
+    while (check == 3) {
+        check = readAndWrite(sockfd, (struct sockaddr *)&cli_addr, clilen);
+    }

     WSACleanup();
     return 0;


liuzianglib beta 2.4.21V29,20170907

liuzianglib beta 2.4.21V29,20170907

 DC_http修改；

--- DC_http.h
+++ DC_http.h
@@ -7,8 +7,8 @@
 #include <string>
 #include <cctype>
 #include <functional>
-//Version 2.4.21V28
-//20170816
+//Version 2.4.21V29
+//20170907

 namespace DC {

@@ -160,12 +160,11 @@
 				headers() = default;

 				template<typename T, typename ...argsType>
-				headers(T&& first, argsType&& ...args) {//÷:http_header(addHeader("name", "value"), addHeader("name2", "value2"), addHeader("name3", "value3")......);
+				headers(T&& first, argsType&& ...args) {//÷:add(addHeader("name", "value"), addHeader("name2", "value2"), addHeader("name3", "value3")......);
 					auto args_value = DC::GetArgs(std::forward<argsType>(args)...);
-					m_data.push_back(std::move(first));
-					for (const auto& p : args_value) {
-						m_data.push_back(std::move(p.get<httpSpace::header>()));
-					}
+					m_data.push_back(first);
+					for (const auto& p : args_value)
+						m_data.push_back(p.get<httpSpace::header>());
 				}

 				headers(const headers&) = default;
@@ -184,9 +183,9 @@
 				template<typename T, typename ...argsType, class = typename std::enable_if_t<!std::is_same<std::decay_t<T>, std::string>::value>>
 				void add(T&& first, argsType&& ...args) {//÷:add(addHeader("name", "value"), addHeader("name2", "value2"), addHeader("name3", "value3")......);
 					auto args_value = DC::GetArgs(std::forward<argsType>(args)...);
-					m_data.emplace_back(std::forward<T>(first));
-					for (auto&& p : args_value)
-						m_data.push_back(std::move(p.get<httpSpace::header>()));
+					m_data.push_back(first);
+					for (const auto& p : args_value)
+						m_data.push_back(p.get<httpSpace::header>());
 				}

 				inline void add(const std::string& input) {
@@ -257,15 +256,10 @@
 				public:
 					base& operator=(const base&) = default;

-					base& operator=(base&& input) {
-						m_title = std::move(input.m_title);
-						m_headers = std::move(input.m_headers);
-						m_body = std::move(input.m_body);
-						return *this;
-					}
-
-				public:
-					inline std::string get_version() { return m_title.version; }
+					base& operator=(base&&) = default;
+
+				public:
+					inline std::string get_version()const { return m_title.version; }

 					inline void set_version(const double& input) { m_title.version = DC::STR::toString(input); }

@@ -287,7 +281,7 @@
 					}

 				protected:
-					DC::Web::http::httpSpace::title m_title;
+					mutable DC::Web::http::httpSpace::title m_title;
 					DC::Web::http::headers m_headers;
 					DC::Web::http::body m_body;
 				};
@@ -384,7 +378,7 @@
 					else return temp + httpSpace::emptyline + m_body;
 				}

-				inline method get_method() {
+				inline method get_method()const {
 					return m_title.method();
 				}

@@ -392,7 +386,7 @@
 					m_title.method() = med;
 				}

-				inline std::string get_uri() {
+				inline std::string get_uri()const {
 					return m_title.URI();
 				}

@@ -424,7 +418,7 @@
 					m_title.StatusCodeDes() = httpSpace::getSC(input);
 				}

-				inline http::status_code get_status_code() {
+				inline http::status_code get_status_code()const {
 					return DC::STR::toType<http::status_code>(m_title.StatusCode());
 				}
 			};


Ensure the CallChannel stays alive while asynchronously creating contents

--- telepathy-farstream/call-channel.c
+++ telepathy-farstream/call-channel.c
@@ -312,6 +312,8 @@
             }
         }
     }
+
+  g_object_unref (self);
 }

 static gboolean
@@ -325,7 +327,7 @@
     return TRUE;

   content = tf_call_content_new_async (self, content_path,
-      &error, content_ready, self);
+      &error, content_ready, g_object_ref (self));

   if (error)
     {


tp_base_contact_list_contacts_changed: set an appropriate actor for changes

--- telepathy-glib/base-contact-list.c
+++ telepathy-glib/base-contact-list.c
@@ -1881,8 +1881,9 @@
   GHashTable *changes;
   GArray *removals;
   TpIntSetIter iter;
-  TpIntSet *pub, *sub, *sub_rp, *unpub, *unsub, *store;
+  TpIntSet *pub, *sub_rp, *unpub, *unsub, *store;
   GObject *sub_chan, *pub_chan, *stored_chan;
+  TpHandle self_handle;

   g_return_if_fail (TP_IS_BASE_CONTACT_LIST (self));

@@ -1892,6 +1893,8 @@
       self->priv->state != TP_CONTACT_LIST_STATE_SUCCESS)
     return;

+  self_handle = tp_base_connection_get_self_handle (self->priv->conn),
+
   sub_chan = (GObject *) self->priv->lists[TP_LIST_HANDLE_SUBSCRIBE];
   pub_chan = (GObject *) self->priv->lists[TP_LIST_HANDLE_PUBLISH];
   stored_chan = (GObject *) self->priv->lists[TP_LIST_HANDLE_STORED];
@@ -1900,8 +1903,10 @@
   g_return_if_fail (G_IS_OBJECT (pub_chan));
   /* stored_chan can legitimately be NULL, though */

+  /* For some changes, we emit signals one by one, because the actor is
+   * different every time. However, for these sets of changes, we do them all
+   * at once, since they'll share an actor. */
   pub = tp_intset_new ();
-  sub = tp_intset_new ();
   unpub = tp_intset_new ();
   unsub = tp_intset_new ();
   sub_rp = tp_intset_new ();
@@ -1935,7 +1940,6 @@
       switch (publish)
         {
         case TP_SUBSCRIPTION_STATE_NO:
-        case TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY:
         case TP_SUBSCRIPTION_STATE_UNKNOWN:
           tp_intset_add (unpub, iter.element);
           break;
@@ -1949,6 +1953,21 @@
               tp_group_mixin_change_members (pub_chan, publish_request,
                   NULL, NULL, pub_lp, NULL, iter.element,
                   TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+              tp_intset_destroy (pub_lp);
+            }
+          break;
+
+        case TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY:
+            {
+              /* Also emit publication request cancellations as we go along:
+               * each one has a different actor */
+              TpIntSet *pub_cancelled = tp_intset_new_containing (
+                  iter.element);
+
+              tp_group_mixin_change_members (pub_chan, "",
+                  NULL, pub_cancelled, NULL, NULL, iter.element,
+                  TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+              tp_intset_destroy (pub_cancelled);
             }
           break;

@@ -1963,17 +1982,38 @@
       switch (subscribe)
         {
         case TP_SUBSCRIPTION_STATE_NO:
-        case TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY:
         case TP_SUBSCRIPTION_STATE_UNKNOWN:
           tp_intset_add (unsub, iter.element);
           break;

+        case TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY:
+            {
+              /* If our subscription request was rejected, the actor is the
+               * other guy, and PERMISSION_DENIED seems a reasonable reason */
+              TpIntSet *sub_rejected = tp_intset_new_containing (iter.element);
+
+              tp_group_mixin_change_members (sub_chan, "",
+                  NULL, sub_rejected, NULL, NULL, iter.element,
+                  TP_CHANNEL_GROUP_CHANGE_REASON_PERMISSION_DENIED);
+              tp_intset_destroy (sub_rejected);
+            }
+          break;
+
         case TP_SUBSCRIPTION_STATE_ASK:
           tp_intset_add (sub_rp, iter.element);
           break;

         case TP_SUBSCRIPTION_STATE_YES:
-          tp_intset_add (sub, iter.element);
+            {
+              /* If our subscription request was accepted, the actor is the
+               * other guy accepting */
+              TpIntSet *sub = tp_intset_new_containing (iter.element);
+
+              tp_group_mixin_change_members (sub_chan, "",
+                  sub, NULL, NULL, NULL, iter.element,
+                  TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+              tp_intset_destroy (sub);
+            }
           break;

         default:
@@ -2008,12 +2048,27 @@
       removals = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 0);
     }

-  /* FIXME: is there a better actor than 0 for these changes? */
+  /* The actor is 0 for removals from subscribe and publish: we don't know
+   * whether it was our idea, or caused by an unknown contact or by server
+   * failure, since those are all represented as No. */
   tp_group_mixin_change_members (sub_chan, "",
-      sub, unsub, NULL, sub_rp, 0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+      NULL, unsub, NULL, NULL, 0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
   tp_group_mixin_change_members (pub_chan, "",
-      pub, unpub, NULL, NULL, 0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
-
+      NULL, unpub, NULL, NULL, 0, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+  /* pub is the set of contacts changing to publish=Yes (i.e. contacts we'll
+   * allow to see our presence), which was presumably our idea. */
+  tp_group_mixin_change_members (pub_chan, "",
+      pub, NULL, NULL, NULL, self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+  /* sub_rp is the set of contacts changing to subscribe=Ask, which was
+   * presumably our idea. */
+  tp_group_mixin_change_members (sub_chan, "", NULL, NULL, NULL, sub_rp,
+      self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+  /* We use actor 0 for the stored list, since people can land on the stored
+   * list for a variety of reasons (if someone has requested we publish to
+   * them, they're temporarily claimed to be stored). */
   if (stored_chan != NULL)
     {
       tp_group_mixin_change_members (stored_chan, "",
@@ -2033,12 +2088,7 @@
             self->priv->conn, changes, removals);
     }

-  /* FIXME: the new D-Bus API doesn't allow us to distinguish between
-   * added-by-user, added-by-server and added-by-remote, or between
-   * removed-by-user, removed-by-server and rejected-by-remote. Do we care? */
-
   tp_intset_destroy (pub);
-  tp_intset_destroy (sub);
   tp_intset_destroy (unpub);
   tp_intset_destroy (unsub);
   tp_intset_destroy (sub_rp);


fixed typo in acceptance code

fixed typo in acceptance code

--- src/RapidAcceptanceLHCb.h
+++ src/RapidAcceptanceLHCb.h
@@ -13,7 +13,7 @@
 			: RapidAcceptance(type, parts, cuts),
 			  zC_(5.4), ptkick_(1.2), zTracker_(9.5),
 			  xSizeTracker_(9.5*0.3), ySizeTracker_(9.5*0.25),
-			  xMinTracker_(9.5*0.001), yMinTracker_(9.5*0.001)
+			  xMinTracker_(9.5*0.01), yMinTracker_(9.5*0.01)
 		{}

 		virtual void getDefaultPtRange(double& min, double& max);


oops missed - alread win_del handled.

oops missed - alread win_del handled.

git-svn-id: 6ac5796aeae0cef97fb47bcc287d4ce899c6fa6e@35749 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/modules/mixer/app_mixer.c
+++ src/modules/mixer/app_mixer.c
@@ -506,15 +506,6 @@
    _mixer_app_dialog_del(dialog, data);
 }

-static void
-_cb_dialog_del(void *obj)
-{
-   E_Dialog *dialog;
-
-   dialog = obj;
-   _mixer_app_dialog_del(dialog, dialog->data);
-}
-
 E_Dialog *
 e_mixer_app_dialog_new(E_Container *con, void (*func)(E_Dialog *dialog, void *data), void *data)
 {
@@ -543,13 +534,13 @@

    _create_ui(dialog, app);

-   e_object_del_attach_func_set(E_OBJECT(dialog), _cb_dialog_del);
-
    e_dialog_button_add(dialog, _("Close"), NULL, _cb_dialog_dismiss, app);
    e_dialog_button_focus_num(dialog, 1);
    e_win_centered_set(dialog->win, 1);
    e_dialog_show(dialog);

+   // FIXME: what if module unloaded while mixer_app dialog up? bad!
+
    return dialog;
 }


Reduce global variables [3]

Reduce global variables [3]

--- src/network/reactor_process.c
+++ src/network/reactor_process.c
@@ -118,9 +118,7 @@
     //no worker
     if (serv->worker_num == 1 && serv->task_worker_num == 0 && serv->max_request == 0 && serv->user_worker_list == NULL)
     {
-        swWorker single_worker;
-        bzero(&single_worker, sizeof(single_worker));
-        return swReactorProcess_loop(&serv->gs->event_workers, &single_worker);
+        return swReactorProcess_loop(&serv->gs->event_workers, &serv->gs->event_workers.workers[0]);
     }

     swWorker *worker;


Make magic aperio compression numbers into constants

--- src/openslide-vendor-aperio.c
+++ src/openslide-vendor-aperio.c
@@ -40,7 +40,10 @@

 static const char APERIO_DESCRIPTION[] = "Aperio";

-static void write_pixel_33003(uint32_t *dest, uint8_t c0, uint8_t c1, uint8_t c2) {
+#define APERIO_COMPRESSION_JP2K_YCBCR 33003
+#define APERIO_COMPRESSION_JP2K_RGB   33005
+
+static void write_pixel_ycbcr(uint32_t *dest, uint8_t c0, uint8_t c1, uint8_t c2) {
   double R = c0 + 1.402 * (c2 - 128);
   double G = c0 - 0.34414 * (c1 - 128) - 0.71414 * (c2 - 128);
   double B = c0 + 1.772 * (c1 - 128);
@@ -67,7 +70,7 @@
   *dest = 255 << 24 | ((uint8_t) R << 16) | ((uint8_t) G << 8) | ((uint8_t) B);
 }

-static void write_pixel_33005(uint32_t *dest, uint8_t c0, uint8_t c1, uint8_t c2) {
+static void write_pixel_rgb(uint32_t *dest, uint8_t c0, uint8_t c1, uint8_t c2) {
   *dest = 255 << 24 | c0 << 16 | c1 << 8 | c2;
 }

@@ -87,7 +90,8 @@
   TIFFGetField(tiff, TIFFTAG_COMPRESSION, &compression_mode);

   // not for us? fallback
-  if ((compression_mode != 33003) && (compression_mode != 33005)) {
+  if ((compression_mode != APERIO_COMPRESSION_JP2K_YCBCR) &&
+      (compression_mode != APERIO_COMPRESSION_JP2K_RGB)) {
     _openslide_generic_tiff_tilereader(tiff, dest, x, y, w, h);
     return;
   }
@@ -162,12 +166,12 @@
       uint8_t c2 = comps[2].data[(y / c2_sub_y) * comps[2].w + (x / c2_sub_x)];

       switch (compression_mode) {
-      case 33003:
-	write_pixel_33003(dest + i, c0, c1, c2);
+      case APERIO_COMPRESSION_JP2K_YCBCR:
+	write_pixel_ycbcr(dest + i, c0, c1, c2);
 	break;

-      case 33005:
-	write_pixel_33005(dest + i, c0, c1, c2);
+      case APERIO_COMPRESSION_JP2K_RGB:
+	write_pixel_rgb(dest + i, c0, c1, c2);
 	break;
       }


sakura: Allocate tile/channel buffers in caller

--- src/openslide-vendor-sakura.c
+++ src/openslide-vendor-sakura.c
@@ -1,7 +1,7 @@
 /*
  *  OpenSlide, a library for reading whole slide image files
  *
- *  Copyright (c) 2007-2013 Carnegie Mellon University
+ *  Copyright (c) 2007-2014 Carnegie Mellon University
  *  Copyright (c) 2011 Google, Inc.
  *  All rights reserved.
  *
@@ -185,12 +185,11 @@
   g_free(osr->levels);
 }

-static uint32_t *read_channel(const char *tileid,
-                              int32_t tile_size,
-                              sqlite3_stmt *stmt,
-                              GError **err) {
-  uint32_t *channeldata = NULL;
-
+static bool read_channel(uint32_t *channeldata,
+                         const char *tileid,
+                         int32_t tile_size,
+                         sqlite3_stmt *stmt,
+                         GError **err) {
   // retrieve compressed tile
   sqlite3_reset(stmt);
   BIND_TEXT_OR_FAIL(stmt, 1, tileid);
@@ -215,41 +214,35 @@
     unlink(tempfile);
     goto FAIL;
   }
-  channeldata = g_slice_alloc(tile_size * tile_size * 4);
-  if (!_openslide_jpeg_read(tempfile, 0, channeldata,
-                            tile_size, tile_size, err)) {
-    g_slice_free1(tile_size * tile_size * 4, channeldata);
-    channeldata = NULL;
-  }
+  bool success = _openslide_jpeg_read(tempfile, 0, channeldata,
+                                      tile_size, tile_size, err);
   unlink(tempfile);
+  return success;

 FAIL:
-  return channeldata;
-}
-
-static uint32_t *read_image(const struct tile *tile,
-                            int32_t tile_size,
-                            sqlite3_stmt *stmt,
-                            GError **err) {
-  uint32_t *tiledata = NULL;
-  uint32_t *red_channel = NULL;
-  uint32_t *green_channel = NULL;
-  uint32_t *blue_channel = NULL;
-
-  red_channel = read_channel(tile->id_red, tile_size, stmt, err);
-  if (!red_channel) {
+  return false;
+}
+
+static bool read_image(uint32_t *tiledata,
+                       const struct tile *tile,
+                       int32_t tile_size,
+                       sqlite3_stmt *stmt,
+                       GError **err) {
+  uint32_t *red_channel = g_slice_alloc(tile_size * tile_size * 4);
+  uint32_t *green_channel = g_slice_alloc(tile_size * tile_size * 4);
+  uint32_t *blue_channel = g_slice_alloc(tile_size * tile_size * 4);
+  bool success = false;
+
+  if (!read_channel(red_channel, tile->id_red, tile_size, stmt, err)) {
     goto OUT;
   }
-  green_channel = read_channel(tile->id_green, tile_size, stmt, err);
-  if (!green_channel) {
+  if (!read_channel(green_channel, tile->id_green, tile_size, stmt, err)) {
     goto OUT;
   }
-  blue_channel = read_channel(tile->id_blue, tile_size, stmt, err);
-  if (!blue_channel) {
+  if (!read_channel(blue_channel, tile->id_blue, tile_size, stmt, err)) {
     goto OUT;
   }

-  tiledata = g_slice_alloc(tile_size * tile_size * 4);
   for (int32_t i = 0; i < tile_size * tile_size; i++) {
     tiledata[i] = 0xff000000 |
                   (red_channel[i] & 0x00ff0000) |
@@ -257,11 +250,13 @@
                   (blue_channel[i] & 0x000000ff);
   }

+  success = true;
+
 OUT:
   g_slice_free1(tile_size * tile_size * 4, red_channel);
   g_slice_free1(tile_size * tile_size * 4, green_channel);
   g_slice_free1(tile_size * tile_size * 4, blue_channel);
-  return tiledata;
+  return success;
 }

 static bool read_tile(openslide_t *osr,
@@ -281,9 +276,11 @@
                                             level, tile_col, tile_row,
                                             &cache_entry);
   if (!tiledata) {
+    tiledata = g_slice_alloc(tile_size * tile_size * 4);
+
     // read tile
-    tiledata = read_image(tile, tile_size, stmt, err);
-    if (!tiledata) {
+    if (!read_image(tiledata, tile, tile_size, stmt, err)) {
+      g_slice_free1(tile_size * tile_size * 4, tiledata);
       return false;
     }


upsampling with summing over

upsampling with summing over

--- src/operator/upsampling-inl.h
+++ src/operator/upsampling-inl.h
@@ -24,6 +24,7 @@
 enum UpSamplingOpInputs {kData, kWeight};
 enum UpSamplingOpOutputs {kOut};
 enum UpSamplingType {kNearest, kBilinear};
+enum UpSamplingMultiInputMode {kConcat, kSum};
 }  // namespace up_enum

 struct UpSamplingParam : public dmlc::Parameter<UpSamplingParam> {
@@ -31,6 +32,7 @@
   index_t num_filter;
   int sample_type;
   int num_args;
+  int multi_input_mode;
   DMLC_DECLARE_PARAMETER(UpSamplingParam) {
     DMLC_DECLARE_FIELD(scale)
     .set_range(1, 1000)
@@ -42,6 +44,13 @@
     .add_enum("nearest", up_enum::kNearest)
     .add_enum("bilinear", up_enum::kBilinear)
     .describe("upsampling method");
+    DMLC_DECLARE_FIELD(multi_input_mode)
+    .add_enum("concat", up_enum::kConcat)
+    .add_enum("sum", up_enum::kSum)
+    .set_default(up_enum::kConcat)
+    .describe("How to handle multiple input. concat means concatenate upsampled "
+    "images along the channel dimension. sum means add all images together, "
+    "only available for nearest neighbor upsampling.");
     DMLC_DECLARE_FIELD(num_args).set_lower_bound(1)
     .describe("Number of inputs to be upsampled. For nearest neighbor "
     "upsampling, this can be 1-N; the size of output will be"
@@ -66,6 +75,9 @@
     using namespace mshadow::expr;
     CHECK_EQ(in_data.size(), param_.num_args);
     CHECK_EQ(out_data.size(), 1);
+    if (req[up_enum::kOut] == kNullOp) {
+      return;
+    }
     Stream<xpu> *s = ctx.get_stream<xpu>();
     Tensor<xpu, 4> out = out_data[up_enum::kOut].get<xpu, 4, real_t>(s);
     if (param_.num_args > 1) {
@@ -74,7 +86,15 @@
         Tensor<xpu, 4> data = in_data[i].get<xpu, 4, real_t>(s);
         int end = begin + data.size(1);
         int scale = out_data[up_enum::kOut].size(2)/in_data[i].size(2);
-        Assign(slice<1>(out, begin, end), req[up_enum::kOut], upsampling_nearest(data, scale));
+        if (param_.multi_input_mode == up_enum::kSum) {
+          if (i == 0) {
+            Assign(out, req[up_enum::kOut], upsampling_nearest(data, scale));
+          } else {
+            out += upsampling_nearest(data, scale);
+          }
+        } else {
+          Assign(slice<1>(out, begin, end), req[up_enum::kOut], upsampling_nearest(data, scale));
+        }
         begin = end;
       }
     } else {
@@ -103,12 +123,21 @@
         mshadow::Shape<2> in_shape = Shape2(input_grad.shape_[2], input_grad.shape_[3]);
         int end = begin + input_grad.size(1);
         int scale = grad.size(2)/in_shape[0];
-        Assign(input_grad, req[i],
-               pool<mshadow::red::sum>(slice<1>(grad, begin, end),
-                                       in_shape,
-                                       scale,
-                                       scale,
-                                       scale));
+        if (param_.multi_input_mode == up_enum::kSum) {
+          Assign(input_grad, req[i],
+                 pool<mshadow::red::sum>(grad,
+                                         in_shape,
+                                         scale,
+                                         scale,
+                                         scale));
+        } else {
+          Assign(input_grad, req[i],
+                 pool<mshadow::red::sum>(slice<1>(grad, begin, end),
+                                         in_shape,
+                                         scale,
+                                         scale,
+                                         scale));
+        }
         begin = end;
       }
     } else {
@@ -171,7 +200,13 @@
           "does not divide output height of " << oh;
         CHECK_EQ(ow%shape[3], 0) << "UpSamplingNearest: input weight of " << shape[3] << \
           "does not divide output weight of " << ow;
-        oshape[1] += shape[1];
+        if (param_.multi_input_mode == up_enum::kSum) {
+          CHECK(oshape[1] == 0 || oshape[1] == shape[1]) << \
+            "Number of channels must be the same when multi_input_mode==sum";
+          oshape[1] = shape[1];
+        } else {
+          oshape[1] += shape[1];
+        }
       }
     } else {
       CHECK_EQ(in_shape->size(), 2) << "Input:[data, weight]";


try to stop agent from yammering about a probe being stuck for a billion seconds

--- src/opticon-agent/probelist.c
+++ src/opticon-agent/probelist.c
@@ -11,8 +11,9 @@
     res->call = NULL;
     res->prev = res->next = NULL;
     res->vcurrent = res->vold = NULL;
-    res->lastpulse = res->lastreply = 0;
+    res->lastpulse = 0;
     res->lastdispatch = time (NULL);
+    res->lastreply = res->lastdispatch - 1;
     res->interval = 0;
     return res;
 }


Removed duplicate initialization of the "rev" variable.

--- src/os/unix/ngx_readv_chain.c
+++ src/os/unix/ngx_readv_chain.c
@@ -91,8 +91,6 @@
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
                    "readv: %d, last:%d", vec.nelts, iov->iov_len);

-    rev = c->read;
-
     do {
         n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);


Remove unused functions in lib/gtl/stl_util

PiperOrigin-RevId: 267626902

--- tensorflow/core/lib/gtl/stl_util.h
+++ tensorflow/core/lib/gtl/stl_util.h
@@ -32,74 +32,6 @@
 namespace tensorflow {
 namespace gtl {

-// Returns a char* pointing to the beginning of a string's internal buffer.
-// The result is a valid "null-terminated byte string", even if *str is empty.
-// Up to C++14 it is not valid to *write* to the null terminator; as of C++17,
-// it is valid to write zero to the null terminator (but not any other value).
-inline char* string_as_array(string* str) { return &*str->begin(); }
-
-// The following vector_as_array functions return raw pointers to the underlying
-// data buffer. The return value is unspecified (but valid) if the input range
-// is empty.
-template <typename T, typename Allocator>
-inline T* vector_as_array(std::vector<T, Allocator>* v) {
-  return v->data();
-}
-
-template <typename T, typename Allocator>
-inline const T* vector_as_array(const std::vector<T, Allocator>* v) {
-  return v->data();
-}
-
-namespace gtl_internal {
-
-// HasMember is true_type or false_type, depending on whether or not
-// T has a __resize_default_init member. Resize will call the
-// __resize_default_init member if it exists, and will call the resize
-// member otherwise.
-template <typename string_type, typename = void>
-struct ResizeUninitializedTraits {
-  using HasMember = std::false_type;
-  static void Resize(string_type* s, size_t new_size) { s->resize(new_size); }
-};
-
-// __resize_default_init is provided by libc++ >= 8.0 and by Google's internal
-// ::string implementation.
-template <typename string_type>
-struct ResizeUninitializedTraits<
-    string_type, absl::void_t<decltype(std::declval<string_type&>()
-                                           .__resize_default_init(237))> > {
-  using HasMember = std::true_type;
-  static void Resize(string_type* s, size_t new_size) {
-    s->__resize_default_init(new_size);
-  }
-};
-
-}  // namespace gtl_internal
-
-// Like str->resize(new_size), except any new characters added to "*str" as a
-// result of resizing may be left uninitialized, rather than being filled with
-// '0' bytes. Typically used when code is then going to overwrite the backing
-// store of the string with known data.
-inline void STLStringResizeUninitialized(string* s, size_t new_size) {
-  gtl_internal::ResizeUninitializedTraits<string>::Resize(s, new_size);
-}
-
-// Calls delete (non-array version) on the SECOND item (pointer) in each pair in
-// the range [begin, end).
-//
-// Note: If you're calling this on an entire container, you probably want to
-// call STLDeleteValues(&container) instead, or use ValueDeleter.
-template <typename ForwardIterator>
-void STLDeleteContainerPairSecondPointers(ForwardIterator begin,
-                                          ForwardIterator end) {
-  while (begin != end) {
-    ForwardIterator temp = begin;
-    ++begin;
-    delete temp->second;
-  }
-}
-
 // Deletes all the elements in an STL container and clears the container. This
 // function is suitable for use with a vector, set, hash_set, or any other STL
 // container which defines sensible begin(), end(), and clear() methods.
@@ -132,13 +64,6 @@
   container->clear();
 }

-// Sorts and removes duplicates from a sequence container.
-template <typename T>
-inline void STLSortAndRemoveDuplicates(T* v) {
-  std::sort(v->begin(), v->end());
-  v->erase(std::unique(v->begin(), v->end()), v->end());
-}
-
 }  // namespace gtl
 }  // namespace tensorflow


Fix double free and deprecate function use

Addressing:
src/XCCDF/xccdf_session.c:498:3: warning: 'xccdf_policy_model_add_cpe_autodetect' is deprecated (declared at src/XCCDF_POLICY/public/xccdf_policy.h:234)

--- src/XCCDF/xccdf_session.c
+++ src/XCCDF/xccdf_session.c
@@ -494,11 +494,11 @@
 			oscap_source_free(source);
 			return 1;
 		}
-		oscap_source_free(source);
-		if (!xccdf_policy_model_add_cpe_autodetect(session->xccdf.policy_model, session->user_cpe)) {
+		if (!xccdf_policy_model_add_cpe_autodetect_source(session->xccdf.policy_model, source)) {
 			oscap_source_free(source);
 			return 1;
 		}
+		oscap_source_free(source);
 	}

 	if (xccdf_session_is_sds(session)) {


change the way

change the way


Fix data object with empty value creation

--- src/pkcs11/framework-pkcs15.c
+++ src/pkcs11/framework-pkcs15.c
@@ -2598,11 +2598,6 @@
 			/* ignore unknown attrs, or flag error? */
 			continue;
 		}
-	}
-
-	if (args.der_encoded.len == 0) {
-		rv = CKR_TEMPLATE_INCOMPLETE;
-		goto out;
 	}

 	rc = sc_pkcs15init_store_data_object(fw_data->p15_card, profile, &args, &data_obj);


(get_unwind_info): _Only call _Uia64_get_kernel_table() on Linux.

(Logical change 1.75)

--- src/_UPT_find_proc_info.c
+++ src/_UPT_find_proc_info.c
@@ -167,7 +167,7 @@
   char path[PATH_MAX];
   unw_dyn_info_t *di;

-#if UNW_TARGET_IA64
+#if UNW_TARGET_IA64 && defined(__linux)
   if (!ui->ktab.start_ip && _Uia64_get_kernel_table (&ui->ktab) < 0)
     return NULL;


Added documentation for the State class.

--- FGState.h
+++ FGState.h
@@ -71,7 +71,7 @@
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

-#define ID_STATE "$Id: FGState.h,v 1.39 2001/08/10 12:21:07 jberndt Exp $"
+#define ID_STATE "$Id: FGState.h,v 1.40 2001/08/11 13:03:33 jberndt Exp $"

 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -95,7 +95,7 @@

 /** Encapsulates the calculation of aircraft state.
     @author Jon S. Berndt
-    @version $Id: FGState.h,v 1.39 2001/08/10 12:21:07 jberndt Exp $
+    @version $Id: FGState.h,v 1.40 2001/08/11 13:03:33 jberndt Exp $
 */

 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -202,36 +202,106 @@
       @return the value of the parameter.
       */
   float GetParameter(string val_string);
+
+  /** Retrieves the JSBSim parameter enumerated item given the text string.
+      @param val_string the parameter string, i.e. "FG_QBAR".
+      @return the JSBSim parameter index (an enumerated type) for the supplied string.
+      */
   eParam GetParameterIndex(string val_string);

-  inline void Seta(float tt) { a = tt; }
-
-  inline float Setsim_time(float tt) {
-    sim_time = tt;
+  /** Sets the speed of sound.
+      @param speed the speed of sound in feet per second.
+      */
+  inline void Seta(float speed) { a = speed; }
+
+  /** Sets the current sim time.
+      @param cur_time the current time
+      @return the current time.
+      */
+  inline float Setsim_time(float cur_time) {
+    sim_time = cur_time;
     return sim_time;
   }
-  inline void  Setdt(float tt) { dt = tt; }
-
-  void SetParameter(eParam, float);
-
+
+  /** Sets the integration time step for the simulation executive.
+      @param delta_t the time step in seconds.
+      */
+  inline void  Setdt(float delta_t) { dt = delta_t; }
+
+  /** Sets the JSBSim parameter to the supplied value.
+      @param prm the JSBSim parameter to set, i.e. FG_RUDDER_POS.
+      @param val the value to give the parameter.
+      */
+  void SetParameter(eParam prm, float val);
+
+  /** Increments the simulation time.
+      @return the new simulation time.
+      */
   inline float IncrTime(void) {
     sim_time+=dt;
     return sim_time;
   }
+
+  /** Initializes the transformation matrices.
+      @param phi the roll angle in radians.
+      @param tht the pitch angle in radians.
+      @param psi the heading angle in radians
+      */
   void InitMatrices(float phi, float tht, float psi);
+
+  /** Calculates the local-to-body and body-to-local conversion matrices.
+      */
   void CalcMatrices(void);
+
+  /** Integrates the quaternion.
+      Given the supplied rotational rate vector and integration rate, the quaternion
+      is integrated. The quaternion is later used to update the transformation
+      matrices.
+      @param vPQR the body rotational rate column vector.
+      @param rate the integration rate in seconds.
+      */
   void IntegrateQuat(FGColumnVector3 vPQR, int rate);
+
+  /** Calculates Euler angles from the local-to-body matrix.
+      @return a reference to the vEuler column vector.
+      */
   FGColumnVector3& CalcEuler(void);
+
+  /** Calculates and returns the stability-to-body axis transformation matrix.
+      @param alpha angle of attack in radians.
+      @param beta angle of sideslip in radians.
+      @return a reference to the stability-to-body transformation matrix.
+      */
   FGMatrix33& GetTs2b(float alpha, float beta);
+
+  /** Retrieves the local-to-body transformation matrix.
+      @return a reference to the local-to-body transformation matrix.
+      */
   FGMatrix33& GetTl2b(void) { return mTl2b; }
-  float GetTl2b(int i, int j) { return mTl2b(i,j);}
+
+  /** Retrieves a specific local-to-body matrix element.
+      @param r matrix row index.
+      @param c matrix column index.
+      @return the matrix element described by the row and column supplied.
+      */
+  float GetTl2b(int r, int c) { return mTl2b(r,c);}
+
+  /** Retrieves the body-to-local transformation matrix.
+      @return a reference to the body-to-local matrix.
+      */
   FGMatrix33& GetTb2l(void) { return mTb2l; }
+
+  /** Retrieves a specific body-to-local matrix element.
+      @param r matrix row index.
+      @param c matrix column index.
+      @return the matrix element described by the row and column supplied.
+      */
   float GetTb2l(int i, int j) { return mTb2l(i,j);}
+
   typedef map<eParam, string> ParamMap;
   ParamMap paramdef;

 private:
-
   float a;                          // speed of sound
   float sim_time, dt;
   float saved_dt;
@@ -245,6 +315,9 @@
   FGColumnVector3 vUVW;
   FGColumnVector3 vLocalVelNED;
   FGColumnVector3 vLocalEuler;
+  FGColumnVector4 vQdot;
+  FGColumnVector4 vTmp;
+  FGColumnVector3 vEuler;

   FGAircraft* Aircraft;
   FGPosition* Position;
@@ -259,10 +332,6 @@
   CoeffMap coeffdef;
   void Debug(void);
   int ActiveEngine;
-
-  FGColumnVector4 vQdot;
-  FGColumnVector4 vTmp;
-  FGColumnVector3 vEuler;
 };

 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


CELIX-272: Fix mem leak in rsa dfi

CELIX-272: Fix mem leak in rsa dfi

--- remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
+++ remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
@@ -388,10 +388,7 @@
             bundleContext_ungetServiceReference(admin->context, arrayList_get(references, i));
         }
     }
-
-    if(references != NULL){
-        arrayList_destroy(references);
-    }
+    arrayList_destroy(references);

     if (reference == NULL) {
         logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "ERROR: expected a reference for service id %s.", serviceId);


even more typos

even more typos

--- src/serialization/serialization.h
+++ src/serialization/serialization.h
@@ -224,7 +224,7 @@
     if (!r || !ar.stream().good()) return false;			\
   } while(0);

-/*! \macro VARING_FIELD(f)
+/*! \macro VARINT_FIELD(f)
  *  \brief tags and serializes the varint \a f
  */
 #define VARINT_FIELD(f)				\
@@ -234,7 +234,7 @@
     if (!ar.stream().good()) return false;	\
   } while(0);

-/*! \macro VARING_FIELD_N(t, f)
+/*! \macro VARINT_FIELD_N(t, f)
  *
  * \brief tags (as \a t) and serializes the varint \a f
  */


Split gexpose out of a more general event handling function.

So far, the only events we've had to deal with have been
GraphicsExpose and NoExpose events.  We're about to start dealing with
selection-related events, so register a more generic function to
handle all events and make gexpose deal with only what it needs to.

--- History.c
+++ History.c
@@ -1188,53 +1188,63 @@
 }

 /* Repaint the bits of the widget that didn't get copied */
-static void
-gexpose(Widget widget, XtPointer closure, XEvent *event,
-        Boolean *continue_to_dispatch)
+static Boolean
+gexpose(HistoryWidget self, XGraphicsExposeEvent *event)
+{
+    XRectangle bbox;
+
+    /* Get the bounding box of the event. */
+    bbox.x = event->x;
+    bbox.y = event->y;
+    bbox.width = event->width;
+    bbox.height = event->height;
+
+    /* Compensate for unprocessed CopyArea requests */
+    dprintf(("process_events() request_id=%lu\n", event->serial));
+    dprintf(("before: %dx%d+%d+%d\n",
+             bbox.width, bbox.height,
+             bbox.x, bbox.y));
+    compensate_bbox(self, event->serial, &bbox);
+    dprintf(("after: %dx%d+%d+%d\n",
+             bbox.width, bbox.height,
+             bbox.x, bbox.y));
+
+    /* Update this portion of the widget. */
+    paint(self, &bbox);
+
+    /* Arrange to stop if this is the last GraphicsExpose event in the
+     * batch. */
+    return event->count != 0;
+}
+
+static void
+process_events(Widget widget, XtPointer closure, XEvent *event,
+               Boolean *continue_to_dispatch)
 {
     HistoryWidget self = (HistoryWidget)widget;
     Display *display = XtDisplay(widget);
     XEvent event_buffer;
-    XRectangle bbox;

     /* Process all of the GraphicsExpose events in one hit */
     for (;;) {
-        XGraphicsExposeEvent *g_event;
-
-        /* Sanity check */
-        assert(event->type == GraphicsExpose || event->type == NoExpose);
-
-        /* Coerce the event */
-        g_event = (XGraphicsExposeEvent *)event;
-
-        /* Get the bounding box of the event */
-        bbox.x = g_event->x;
-        bbox.y = g_event->y;
-        bbox.width = g_event->width;
-        bbox.height = g_event->height;
-
-        /* Compensate for unprocessed CopyArea requests */
-        dprintf(("gexpose() request_id=%lu\n", g_event->serial));
-        dprintf(("before: %dx%d+%d+%d\n", bbox.width, bbox.height, bbox.x,
-                 bbox.y));
-        compensate_bbox(self, g_event->serial, &bbox);
-        dprintf(("after: %dx%d+%d+%d\n", bbox.width, bbox.height, bbox.x,
-                 bbox.y));
-
-        /* Stop drawing stuff if the widget is obscured */
-        if (event->type == NoExpose) {
+        switch (event->type) {
+        case NoExpose:
+            /* Stop drawing if the widget is obscured. */
             return;
-        }
-
-        /* Update this portion of the history */
-        paint(self, &bbox);
-
-        /* Bail out if this is the last GraphicsExpose event */
-        if (g_event->count < 1) {
+
+        case GraphicsExpose:
+            /* Continue processing graphics expose evens until we've
+             * processed the entire batch. */
+            if (!gexpose(self, &event->xgraphicsexpose)) {
+                return;
+            }
+
+        default:
+            dprintf(("ignoring unknown event type: %d\n", event->type));
             return;
         }

-        /* Otherwise grab the next one */
+        /* Otherwise grab the next event */
         XNextEvent(display, &event_buffer);
         event = &event_buffer;
     }
@@ -1293,7 +1303,7 @@
                                  GCBackground | GCFont, &values);

     /* Register to receive GraphicsExpose events */
-    XtAddEventHandler(widget, 0, True, gexpose, NULL);
+    XtAddEventHandler(widget, 0, True, process_events, NULL);

     /* Register to receive motion callbacks */
     XtAddEventHandler(widget, PointerMotionMask, False, motion_cb, NULL);