Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#11028) error on loading savegame
Home

[Freeciv-Dev] (PR#11028) error on loading savegame

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Erki.Savisaar@xxxxxx
Subject: [Freeciv-Dev] (PR#11028) error on loading savegame
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Nov 2004 18:39:37 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11028 >

And here is a patch that removes the limitation entirely.

jason

Index: utility/mem.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/mem.c,v
retrieving revision 1.10
diff -u -r1.10 mem.c
--- utility/mem.c       1 Nov 2004 11:47:33 -0000       1.10
+++ utility/mem.c       19 Nov 2004 02:38:47 -0000
@@ -48,19 +48,15 @@
 static void sanity_check_size(size_t size, const char *called_as,
                              int line, const char *file)
 {
-  /* We're not allowed to allocate more than 30 Mb - the program will exit
-   * if someone tries.  This is a sanity measure since some parts of the code
-   * could try to allocate unboundedly large amounts of memory if given the
-   * wrong input. */
-  const size_t max_alloc_size = 30 * (1 << 20);
+  /* There used to be a sanity check here that would abort if more than
+   * 30 megabytes were allocated.  Unfortunately this didn't work because
+   * savegame loading can potentially use a huge amount of memory for large
+   * games.  Another problem is it doesn't help much because there's nothing
+   * preventing a large number of smaller allocations. */
 
   if (size == 0) {
     freelog(LOG_VERBOSE, "Warning: %s with size %lu at line %d of %s",
            called_as, (unsigned long)size, line, file);
-  } else if (size > max_alloc_size) {
-    die("Overly large request in %s with size %lu > %lu at line %d of %s",
-        called_as, (unsigned long)size, (unsigned long)max_alloc_size,
-        line, file);
   }
 }
 

[Prev in Thread] Current Thread [Next in Thread]