##// END OF EJS Templates
bdiff: fix pointer aliasing
Matt Mackall -
r15222:73015301 default
parent child Browse files
Show More
@@ -366,11 +366,11 b' nomem:'
366
366
367 static PyObject *bdiff(PyObject *self, PyObject *args)
367 static PyObject *bdiff(PyObject *self, PyObject *args)
368 {
368 {
369 char *sa, *sb;
369 char *sa, *sb, *rb;
370 PyObject *result = NULL;
370 PyObject *result = NULL;
371 struct line *al, *bl;
371 struct line *al, *bl;
372 struct hunk l, *h;
372 struct hunk l, *h;
373 char encode[12], *rb;
373 uint32_t encode[3];
374 int an, bn, len = 0, la, lb, count;
374 int an, bn, len = 0, la, lb, count;
375
375
376 if (!PyArg_ParseTuple(args, "s#s#:bdiff", &sa, &la, &sb, &lb))
376 if (!PyArg_ParseTuple(args, "s#s#:bdiff", &sa, &la, &sb, &lb))
@@ -407,9 +407,9 b' static PyObject *bdiff(PyObject *self, P'
407 for (h = l.next; h; h = h->next) {
407 for (h = l.next; h; h = h->next) {
408 if (h->a1 != la || h->b1 != lb) {
408 if (h->a1 != la || h->b1 != lb) {
409 len = bl[h->b1].l - bl[lb].l;
409 len = bl[h->b1].l - bl[lb].l;
410 *(uint32_t *)(encode) = htonl(al[la].l - al->l);
410 encode[0] = htonl(al[la].l - al->l);
411 *(uint32_t *)(encode + 4) = htonl(al[h->a1].l - al->l);
411 encode[1] = htonl(al[h->a1].l - al->l);
412 *(uint32_t *)(encode + 8) = htonl(len);
412 encode[2] = htonl(len);
413 memcpy(rb, encode, 12);
413 memcpy(rb, encode, 12);
414 memcpy(rb + 12, bl[lb].l, len);
414 memcpy(rb + 12, bl[lb].l, len);
415 rb += 12 + len;
415 rb += 12 + len;
General Comments 0
You need to be logged in to leave comments. Login now