test: fix various leaks in the tests
This commit is contained in:
parent
373cd80081
commit
2cee5fb36c
|
@ -778,7 +778,7 @@ InitAndStartDevices(void)
|
|||
/**
|
||||
* Free the given device class and reset the pointer to NULL.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
FreeDeviceClass(int type, void **class)
|
||||
{
|
||||
if (!(*class))
|
||||
|
|
|
@ -331,6 +331,8 @@ extern _X_EXPORT Bool InitButtonClassDeviceStruct(DeviceIntPtr /*device */ ,
|
|||
|
||||
extern _X_INTERNAL ValuatorClassPtr AllocValuatorClass(ValuatorClassPtr src,
|
||||
int numAxes);
|
||||
extern _X_INTERNAL void FreeDeviceClass(int type, void **class);
|
||||
|
||||
|
||||
extern _X_EXPORT Bool InitValuatorClassDeviceStruct(DeviceIntPtr /*device */ ,
|
||||
int /*numAxes */ ,
|
||||
|
|
17
test/input.c
17
test/input.c
|
@ -154,6 +154,9 @@ dix_init_valuators(void)
|
|||
assert(axis->scroll.type == SCROLL_TYPE_VERTICAL);
|
||||
assert(axis->scroll.increment == 3.0);
|
||||
assert(axis->scroll.flags == SCROLL_FLAG_NONE);
|
||||
|
||||
FreeDeviceClass(ValuatorClass, (void**)&val);
|
||||
free(dev.last.scroll); /* sigh, allocated but not freed by the valuator functions */
|
||||
}
|
||||
|
||||
/* just check the known success cases, and that error cases set the client's
|
||||
|
@ -282,6 +285,7 @@ dix_event_to_core(int type)
|
|||
ev.detail.key = 0;
|
||||
rc = EventToCore((InternalEvent *) &ev, &core, &count);
|
||||
test_event();
|
||||
free(core);
|
||||
|
||||
x = 1;
|
||||
y = 2;
|
||||
|
@ -289,6 +293,7 @@ dix_event_to_core(int type)
|
|||
ev.root_y = y;
|
||||
rc = EventToCore((InternalEvent *) &ev, &core, &count);
|
||||
test_event();
|
||||
free(core);
|
||||
|
||||
x = 0x7FFF;
|
||||
y = 0x7FFF;
|
||||
|
@ -296,6 +301,7 @@ dix_event_to_core(int type)
|
|||
ev.root_y = y;
|
||||
rc = EventToCore((InternalEvent *) &ev, &core, &count);
|
||||
test_event();
|
||||
free(core);
|
||||
|
||||
x = 0x8000; /* too high */
|
||||
y = 0x8000; /* too high */
|
||||
|
@ -307,6 +313,7 @@ dix_event_to_core(int type)
|
|||
assert(count == 1);
|
||||
assert(core->u.keyButtonPointer.rootX != x);
|
||||
assert(core->u.keyButtonPointer.rootY != y);
|
||||
free(core);
|
||||
|
||||
x = 0x7FFF;
|
||||
y = 0x7FFF;
|
||||
|
@ -316,16 +323,19 @@ dix_event_to_core(int type)
|
|||
ev.time = time;
|
||||
rc = EventToCore((InternalEvent *) &ev, &core, &count);
|
||||
test_event();
|
||||
free(core);
|
||||
|
||||
detail = 1;
|
||||
ev.detail.key = detail;
|
||||
rc = EventToCore((InternalEvent *) &ev, &core, &count);
|
||||
test_event();
|
||||
free(core);
|
||||
|
||||
detail = 0xFF; /* highest value */
|
||||
ev.detail.key = detail;
|
||||
rc = EventToCore((InternalEvent *) &ev, &core, &count);
|
||||
test_event();
|
||||
free(core);
|
||||
|
||||
detail = 0xFFF; /* too big */
|
||||
ev.detail.key = detail;
|
||||
|
@ -338,6 +348,7 @@ dix_event_to_core(int type)
|
|||
ev.corestate = state;
|
||||
rc = EventToCore((InternalEvent *) &ev, &core, &count);
|
||||
test_event();
|
||||
free(core);
|
||||
|
||||
state = 0x10000; /* too big */
|
||||
ev.corestate = state;
|
||||
|
@ -347,6 +358,7 @@ dix_event_to_core(int type)
|
|||
assert(count == 1);
|
||||
assert(core->u.keyButtonPointer.state != state);
|
||||
assert(core->u.keyButtonPointer.state == (state & 0xFFFF));
|
||||
free(core);
|
||||
|
||||
#undef test_event
|
||||
}
|
||||
|
@ -1197,6 +1209,7 @@ dix_input_attributes(void)
|
|||
|
||||
new = DuplicateInputAttributes(orig);
|
||||
assert(memcmp(orig, new, sizeof(InputAttributes)) == 0);
|
||||
FreeInputAttributes(new);
|
||||
|
||||
orig->product = xnfstrdup("product name");
|
||||
new = DuplicateInputAttributes(orig);
|
||||
|
@ -1330,6 +1343,7 @@ dix_input_valuator_masks(void)
|
|||
}
|
||||
|
||||
valuator_mask_free(&mask);
|
||||
valuator_mask_free(©);
|
||||
assert(mask == NULL);
|
||||
}
|
||||
|
||||
|
@ -1361,6 +1375,9 @@ dix_valuator_mode(void)
|
|||
valuator_set_mode(&dev, VALUATOR_MODE_ALL_AXES, Relative);
|
||||
for (i = 0; i < num_axes; i++)
|
||||
assert(valuator_get_mode(&dev, i) == Relative);
|
||||
|
||||
FreeDeviceClass(ValuatorClass, (void**)&dev.valuator);
|
||||
free(dev.last.scroll); /* sigh, allocated but not freed by the valuator functions */
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -266,6 +266,8 @@ test_nt_list_append(void)
|
|||
i++;
|
||||
}
|
||||
assert(i == 11);
|
||||
|
||||
free(foo);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -300,6 +302,8 @@ test_nt_list_insert(void)
|
|||
i++;
|
||||
}
|
||||
assert(i == 11);
|
||||
|
||||
free(foo);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -176,13 +176,16 @@ static void logging_format(void)
|
|||
char read_buf[2048];
|
||||
char *logmsg;
|
||||
uintptr_t ptr;
|
||||
char *fname = NULL;
|
||||
|
||||
/* set up buf to contain ".....end" */
|
||||
memset(buf, '.', sizeof(buf));
|
||||
strcpy(&buf[sizeof(buf) - 4], "end");
|
||||
|
||||
LogInit(log_file_path, NULL);
|
||||
fname = (char*)LogInit(log_file_path, NULL);
|
||||
assert(fname != NULL);
|
||||
assert((f = fopen(log_file_path, "r")));
|
||||
free(fname);
|
||||
|
||||
#define read_log_msg(msg) do { \
|
||||
msg = fgets(read_buf, sizeof(read_buf), f); \
|
||||
|
|
|
@ -75,6 +75,8 @@ xkb_get_rules_test(void)
|
|||
assert(strcmp(rmlvo.layout, XKB_DFLT_LAYOUT) == 0);
|
||||
assert(strcmp(rmlvo.variant, XKB_DFLT_VARIANT) == 0);
|
||||
assert(strcmp(rmlvo.options, XKB_DFLT_OPTIONS) == 0);
|
||||
|
||||
XkbFreeRMLVOSet(&rmlvo, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,6 +116,7 @@ xkb_set_rules_test(void)
|
|||
assert(strcmp(rmlvo.options, rmlvo_new.options) == 0);
|
||||
|
||||
XkbFreeRMLVOSet(&rmlvo, FALSE);
|
||||
XkbFreeRMLVOSet(&rmlvo_new, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,6 +142,7 @@ xkb_set_get_rules_test(void)
|
|||
|
||||
/* pass 1 */
|
||||
XkbSetRulesDflts(&rmlvo);
|
||||
XkbFreeRMLVOSet(&rmlvo, FALSE);
|
||||
XkbGetRulesDflts(&rmlvo);
|
||||
|
||||
/* Make a backup copy */
|
||||
|
@ -159,12 +163,16 @@ xkb_set_get_rules_test(void)
|
|||
assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
|
||||
assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
|
||||
|
||||
XkbFreeRMLVOSet(&rmlvo, FALSE);
|
||||
XkbGetRulesDflts(&rmlvo);
|
||||
assert(strcmp(rmlvo.rules, rmlvo_backup.rules) == 0);
|
||||
assert(strcmp(rmlvo.model, rmlvo_backup.model) == 0);
|
||||
assert(strcmp(rmlvo.layout, rmlvo_backup.layout) == 0);
|
||||
assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
|
||||
assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
|
||||
|
||||
XkbFreeRMLVOSet(&rmlvo, FALSE);
|
||||
XkbFreeRMLVOSet(&rmlvo_backup, FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -63,17 +63,24 @@ xfree86_option_list_duplicate(void)
|
|||
|
||||
assert(strcmp(val1, v1) == 0);
|
||||
assert(strcmp(val1, val2) == 0);
|
||||
free(val1);
|
||||
free(val2);
|
||||
|
||||
val1 = xf86CheckStrOption(options, o2, "1");
|
||||
val2 = xf86CheckStrOption(duplicate, o2, "2");
|
||||
|
||||
assert(strcmp(val1, v2) == 0);
|
||||
assert(strcmp(val1, val2) == 0);
|
||||
free(val1);
|
||||
free(val2);
|
||||
|
||||
a = xf86FindOption(options, o_null);
|
||||
b = xf86FindOption(duplicate, o_null);
|
||||
assert(a);
|
||||
assert(b);
|
||||
|
||||
xf86OptionListFree(duplicate);
|
||||
xf86OptionListFree(options);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue