ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/Jan-Apr/Defaults

This is Defaults in view mode; [Up]


Date: Sun 16-Apr-1989 06:09:19 From: Unknown Subject: Defaults I am trying to make use of the "defaults database" within a program that I am writing and am having a little bit of trouble with it. I am getting a segmentation violation when I make a call to "NXRegisterDefaults". To isolate the problem, I created a brand new application with the interface builder and decompiled the program without doing anything in the IB so that I could be assured that any other code I was writing wasn't messing things up. Anyway, I followed the directions in chapter 8 (Support Objects and Functions) page 7, and created the following code: ---- +initialize { static NXDefaultsVector myDefaults = { {"Misc", "1234"} }; NXRegisterDefaults("MyApp", myDefaults); return self; } ---- Using the debugger, I found that the segmentation fault happens within a "strcmp" in the source file defaults.c (line 61)* which is being called from "NXRegisterDefaults("MyApp", myDefaults);" from the above code. I don't think I am doing anything wrong, so what is the problem? *This brings up an interesting question. What is the purpose of NeXT compiling all their libraries with the debug option when they don't provide the code for us to look into? Is this just temporary because the OS is still beta? ------------------------------------------------------------------------------ Bryce Jasmer | c/o Support Staff | Internet email: jasmerb@cs.orst.edu Computer Science Dept. | Oregon State University | NeXT voice mail: jasmerb@hobbes.cs.orst.edu Corvallis, OR 97331 | ------------------------------------------------------------------------------ >From: ali@polya.Stanford.EDU (Ali T. Ozer)
Date: Sun 16-Apr-1989 16:33:31 From: Unknown Subject: Re: Defaults In article <10013@orstcs.CS.ORST.EDU> Bryce Jasmer writes: > > static NXDefaultsVector myDefaults = { > {"Misc", "1234"} > }; > > NXRegisterDefaults("MyApp", myDefaults); > >Using the debugger, I found that the segmentation fault happens within a >"strcmp" in the source file defaults.c ... Looking at the above code, there's no way for NXRegisterDefaults to know when to stop reading your array. You need to put a NULL at the end of your list as a default name: {"Misc", "1234"}, {NULL} Ali Ozer, NeXT Developer Support aozer@NeXT.com >From: avie@wb1.cs.cmu.edu (Avadis Tevanian)
Date: Sun 16-Apr-1989 18:04:15 From: Unknown Subject: Re: Defaults In article <10013@orstcs.CS.ORST.EDU> jasmerb@mist.CS.ORST.EDU (Bryce Jasmer) writes: >I am trying to make use of the "defaults database" within a program that >I am writing and am having a little bit of trouble with it. I am getting >a segmentation violation when I make a call to "NXRegisterDefaults". >+initialize >{ > static NXDefaultsVector myDefaults = { > {"Misc", "1234"} > }; > > NXRegisterDefaults("MyApp", myDefaults); > return self; >} You need to NULL terminate the list of defaults. Try: static NXDefaultsVector myDefaults = { {"Misc", "1234"}, { NULL, NULL} }; I will tell our documentation people to make this clear in the TechDoc (the example there in 0.8 documentation has the same problem).

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.