Author: akhaldi
Date: Mon Mar 30 09:25:59 2015
New Revision: 66973
URL: http://svn.reactos.org/svn/reactos?rev=66973&view=rev
Log:
[SORT] Addendum to r66972. Since we're still playing the "Guess what the real changes are" game despite talking about it over and over, I just decided to join you guys. Fix the an IRP leak. Also tabs => spaces. More will come as long as the game does not stop. No svn history was unnecessarily changed (further) while making this commit.
Modified:
trunk/reactos/base/applications/cmdutils/sort/sort.c
Modified: trunk/reactos/base/applications/cmdutils/sort/sort.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/sort/sort.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/sort/sort.c [iso-8859-1] Mon Mar 30 09:25:59 2015
@@ -1,39 +1,31 @@
/*
- * SORT - reads line of a file and sorts them in order
- * Copyright 1995 Jim Lynch
+ * PROJECT: SORT - Adapted for ReactOS
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Reads line of a file and sorts them in order
+ * COPYRIGHT: Copyright 1995 Jim Lynch
*
- * Adapted for ReactOS
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <stdlib.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <malloc.h>
-
-#define MAXRECORDS 65536 /* maximum number of records that can be sorted */
-#define MAXLEN 4095 /* maximum record length */
-
-int rev; /* reverse flag */
-int help; /* help flag */
-int sortcol; /* sort column */
-int err = 0; /* error counter */
-
-int
-cmpr(const void *a, const void *b)
+
+#define MAXRECORDS 65536 /* maximum number of records that can be sorted */
+#define MAXLEN 4095 /* maximum record length */
+
+/* Reverse flag */
+int rev;
+
+/* Help flag */
+int help;
+
+/* Sort column */
+int sortcol;
+
+/* Error counter */
+int err = 0;
+
+int cmpr(const void *a, const void *b)
{
char *A, *B;
@@ -43,31 +35,47 @@
if (sortcol > 0)
{
if (strlen(A) > sortcol)
+ {
A += sortcol;
+ }
else
+ {
A = "";
+ }
if (strlen(B) > sortcol)
+ {
B += sortcol;
+ }
else
+ {
B = "";
+ }
}
if (!rev)
+ {
return strcmp(A, B);
+ }
else
+ {
return strcmp(B, A);
+ }
}
-void
-usage(void)
+void usage(void)
{
fputs("SORT\n", stderr);
- fputs("Sorts input and writes output to a file, console or a device.\n", stderr);
+ fputs("Sorts input and writes output to a file, console or a device.\n",
+ stderr);
if (err)
+ {
fputs("Invalid parameter\n", stderr);
-
- fputs(" SORT [options] < [drive:1][path1]file1 > [drive2:][path2]file2\n", stderr);
+ }
+
+ fputs(" SORT [options] < [drive:1][path1]file1 > [drive2:][path2]file2\n",
+ stderr);
+
fputs(" Command | SORT [options] > [drive:][path]file\n", stderr);
fputs(" Options:\n", stderr);
fputs(" /R Reverse order\n", stderr);
@@ -79,9 +87,10 @@
{
char temp[MAXLEN + 1];
char **list;
- char *cp; /* option character pointer */
- int nr;
- int i;
+
+ /* Option character pointer */
+ char *cp;
+ int i, nr;
sortcol = 0;
rev = 0;
@@ -105,7 +114,9 @@
case '+':
sortcol = atoi(cp + 1);
if (sortcol)
+ {
sortcol--;
+ }
break;
default:
@@ -130,10 +141,14 @@
for (nr = 0; nr < MAXRECORDS; nr++)
{
if (fgets(temp, MAXLEN, stdin) == NULL)
+ {
break;
+ }
if(strlen(temp))
- temp[strlen(temp)-1]='\0';
+ {
+ temp[strlen(temp) - 1] = '\0';
+ }
list[nr] = (char *) malloc(strlen(temp) + 1);
if (list[nr] == NULL)
@@ -146,7 +161,6 @@
free(list[i]);
}
free(list);
-
exit(3);
}
@@ -168,12 +182,12 @@
exit(4);
}
- qsort((void *) list, nr, sizeof(char *), cmpr);
+ qsort((void *)list, nr, sizeof(char *), cmpr);
for (i = 0; i < nr; i++)
{
fputs(list[i], stdout);
- fputs("\n",stdout);
+ fputs("\n", stdout);
}
/* Cleanup memory */
@@ -182,8 +196,6 @@
free(list[i]);
}
free(list);
-
return 0;
}
-
/* EOF */
Author: hbelusca
Date: Sun Mar 29 22:26:24 2015
New Revision: 66972
URL: http://svn.reactos.org/svn/reactos?rev=66972&view=rev
Log:
[SORT]
- Don't leak memory, see CORE-8205 for more details.
- Replace tabs with spaces.
Modified:
trunk/reactos/base/applications/cmdutils/sort/sort.c
Modified: trunk/reactos/base/applications/cmdutils/sort/sort.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/sort/sort.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/sort/sort.c [iso-8859-1] Sun Mar 29 22:26:24 2015
@@ -1,60 +1,61 @@
/*
-* SORT - reads line of a file and sorts them in order
-* Copyright 1995 Jim Lynch
-*
-* Adapted for ReactOS
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ * SORT - reads line of a file and sorts them in order
+ * Copyright 1995 Jim Lynch
+ *
+ * Adapted for ReactOS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <stdio.h>
#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
#include <malloc.h>
-#define MAXRECORDS 65536 /* maximum number of records that can be
- * sorted */
-#define MAXLEN 4095 /* maximum record length */
+#define MAXRECORDS 65536 /* maximum number of records that can be sorted */
+#define MAXLEN 4095 /* maximum record length */
-int rev; /* reverse flag */
-int help; /* help flag */
-int sortcol; /* sort column */
-int err = 0; /* error counter */
+int rev; /* reverse flag */
+int help; /* help flag */
+int sortcol; /* sort column */
+int err = 0; /* error counter */
int
cmpr(const void *a, const void *b)
{
- char *A, *B;
+ char *A, *B;
A = *(char **) a;
B = *(char **) b;
- if (sortcol > 0) {
- if (strlen(A) > sortcol)
- A += sortcol;
- else
- A = "";
- if (strlen(B) > sortcol)
- B += sortcol;
- else
- B = "";
+ if (sortcol > 0)
+ {
+ if (strlen(A) > sortcol)
+ A += sortcol;
+ else
+ A = "";
+ if (strlen(B) > sortcol)
+ B += sortcol;
+ else
+ B = "";
}
+
if (!rev)
- return strcmp(A, B);
+ return strcmp(A, B);
else
- return strcmp(B, A);
+ return strcmp(B, A);
}
void
@@ -62,79 +63,126 @@
{
fputs("SORT\n", stderr);
fputs("Sorts input and writes output to a file, console or a device.\n", stderr);
+
if (err)
- fputs("Invalid parameter\n", stderr);
+ fputs("Invalid parameter\n", stderr);
+
fputs(" SORT [options] < [drive:1][path1]file1 > [drive2:][path2]file2\n", stderr);
fputs(" Command | SORT [options] > [drive:][path]file\n", stderr);
fputs(" Options:\n", stderr);
- fputs(" /R Reverse order\n", stderr);
- fputs(" /+n Start sorting with column n\n", stderr);
- fputs(" /? Help\n", stderr);
+ fputs(" /R Reverse order\n", stderr);
+ fputs(" /+n Start sorting with column n\n", stderr);
+ fputs(" /? Help\n", stderr);
}
int main(int argc, char **argv)
{
- char temp[MAXLEN + 1];
- char **list;
- char *cp; /* option character pointer */
- int nr;
- int i;
-
+ char temp[MAXLEN + 1];
+ char **list;
+ char *cp; /* option character pointer */
+ int nr;
+ int i;
sortcol = 0;
rev = 0;
- while (--argc) {
- if (*(cp = *++argv) == '/') {
- switch (cp[1]) {
- case 'R':
- case 'r':
- rev = 1;
- break;
- case '?':
- case 'h':
- case 'H':
- help = 1;
- break;
- case '+':
- sortcol = atoi(cp + 1);
- if (sortcol)
- sortcol--;
- break;
- default:
- err++;
- }
- }
+ while (--argc)
+ {
+ if (*(cp = *++argv) == '/')
+ {
+ switch (cp[1])
+ {
+ case 'R':
+ case 'r':
+ rev = 1;
+ break;
+
+ case '?':
+ case 'h':
+ case 'H':
+ help = 1;
+ break;
+
+ case '+':
+ sortcol = atoi(cp + 1);
+ if (sortcol)
+ sortcol--;
+ break;
+
+ default:
+ err++;
+ }
+ }
}
- if (err || help) {
- usage();
- exit(1);
+
+ if (err || help)
+ {
+ usage();
+ exit(1);
}
+
list = (char **) malloc(MAXRECORDS * sizeof(char *));
- if (list == NULL) {
+ if (list == NULL)
+ {
fputs("SORT: Insufficient memory\n", stderr);
exit(3);
}
- for (nr = 0; nr < MAXRECORDS; nr++) {
- if (fgets(temp, MAXLEN, stdin) == NULL)
- break;
- if(strlen(temp))
- temp[strlen(temp)-1]='\0';
- list[nr] = (char *) malloc(strlen(temp) + 1);
- if (list[nr] == NULL) {
- fputs("SORT: Insufficient memory\n", stderr);
- exit(3);
- }
- strcpy(list[nr], temp);
+
+ for (nr = 0; nr < MAXRECORDS; nr++)
+ {
+ if (fgets(temp, MAXLEN, stdin) == NULL)
+ break;
+
+ if(strlen(temp))
+ temp[strlen(temp)-1]='\0';
+
+ list[nr] = (char *) malloc(strlen(temp) + 1);
+ if (list[nr] == NULL)
+ {
+ fputs("SORT: Insufficient memory\n", stderr);
+
+ /* Cleanup memory */
+ for (i = 0; i < nr; i++)
+ {
+ free(list[i]);
+ }
+ free(list);
+
+ exit(3);
+ }
+
+ strcpy(list[nr], temp);
}
- if (nr == MAXRECORDS) {
- fputs("SORT: number of records exceeds maximum\n", stderr);
- exit(4);
+
+ if (nr == MAXRECORDS)
+ {
+ fputs("SORT: number of records exceeds maximum\n", stderr);
+
+ /* Cleanup memory */
+ for (i = 0; i < nr; i++)
+ {
+ free(list[i]);
+ }
+ free(list);
+
+ /* Bail out */
+ exit(4);
}
+
qsort((void *) list, nr, sizeof(char *), cmpr);
- for (i = 0; i < nr; i++) {
- fputs(list[i], stdout);
- fputs("\n",stdout);
+
+ for (i = 0; i < nr; i++)
+ {
+ fputs(list[i], stdout);
+ fputs("\n",stdout);
}
+
+ /* Cleanup memory */
+ for (i = 0; i < nr; i++)
+ {
+ free(list[i]);
+ }
+ free(list);
+
return 0;
}
Author: jimtabor
Date: Sun Mar 29 16:25:50 2015
New Revision: 66968
URL: http://svn.reactos.org/svn/reactos?rev=66968&view=rev
Log:
[NtUser]
- Fix the transfer of a global cursor while using ATI. See CORE-9436.
Modified:
trunk/reactos/win32ss/user/ntuser/input.c
Modified: trunk/reactos/win32ss/user/ntuser/input.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/input.…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/input.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/input.c [iso-8859-1] Sun Mar 29 16:25:50 2015
@@ -523,8 +523,15 @@
MsqDestroyMessageQueue(ptiFrom);
+ if (CurIcon)
+ {
+ // Could be global. Keep it above the water line!
+ UserReferenceObject(CurIcon);
+ }
+
if (CurIcon && UserObjectInDestroy(UserHMGetHandle(CurIcon)))
{
+ UserDereferenceObject(CurIcon);
CurIcon = NULL;
}
@@ -533,8 +540,8 @@
// Pass cursor From if To is null. Pass test_SetCursor parent_id == current pti ID.
if (CurIcon && ptiTo->MessageQueue->CursorObject == NULL)
{
+ ERR("ptiTo receiving ptiFrom Cursor\n");
ptiTo->MessageQueue->CursorObject = CurIcon;
- UserReferenceObject(CurIcon);
}
ptiFrom->MessageQueue->cThreads++;