Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Aug 2015 06:34:24 GMT
From:      clord@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r289576 - soc2015/clord/head/sys/contrib/ficl
Message-ID:  <201508110634.t7B6YO1l070325@socsvn.freebsd.org>

index | next in thread | raw e-mail

Author: clord
Date: Tue Aug 11 06:34:24 2015
New Revision: 289576
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289576

Log:
  Properly intialize the ficlDictionary struct in ficlDictionaryCreateHashed
  function. In particular, dictionary->base needed special attention since
  we want to be able to resize our dictionary, and changing it to a pointer
  rather than an array of size 1 requires an extra memory allocation.
  

Modified:
  soc2015/clord/head/sys/contrib/ficl/dictionary.c

Modified: soc2015/clord/head/sys/contrib/ficl/dictionary.c
==============================================================================
--- soc2015/clord/head/sys/contrib/ficl/dictionary.c	Tue Aug 11 06:27:31 2015	(r289575)
+++ soc2015/clord/head/sys/contrib/ficl/dictionary.c	Tue Aug 11 06:34:24 2015	(r289576)
@@ -461,11 +461,14 @@
     ficlDictionary *dictionary;
     size_t nAlloc;
 
-    nAlloc =  sizeof(ficlDictionary) + (size * sizeof (ficlCell))
-            + sizeof(ficlHash) + (bucketCount - 1) * sizeof (ficlWord *);
+    nAlloc = sizeof(ficlHash) + (size * sizeof (ficlCell))
+                              + (bucketCount - 1) * sizeof (ficlWord *);
 
-    dictionary = ficlMalloc(nAlloc);
+    dictionary = ficlMalloc(sizeof(ficlDictionary));
     FICL_SYSTEM_ASSERT(system, dictionary != NULL);
+    memset(dictionary, 0, sizeof(ficlDictionary));
+    dictionary->base = ficlMalloc(nAlloc);
+    FICL_SYSTEM_ASSERT(system, dictionary->base != NULL);
 
     dictionary->size = size;
 	dictionary->system = system;


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508110634.t7B6YO1l070325>