Not part of the build (without these changes it doesn't build).

Fixed the input string variable name in1/in.
CreateACString takes three params not two.
variables living in nsCOMPtrs should not be left alive past xpcom shutdown.
This commit is contained in:
timeless%mozdev.org 2003-01-22 07:51:44 +00:00
parent eba1c08907
commit 1d187936dc

View File

@ -45,35 +45,37 @@ int
main(void)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("NS_InitXPCOM2 failed\n");
return -1;
}
{
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("NS_InitXPCOM2 failed\n");
return -1;
}
nsCOMPtr<nsIStringService> stringService = do_GetService("@mozilla.org/stringService;1");
if (!stringService) {
printf("String Service not found.\n");
return -1;
}
nsCOMPtr<nsIStringService> stringService = do_GetService("@mozilla.org/stringService;1");
if (!stringService) {
printf("String Service not found.\n");
return -1;
}
char *in1 = "The quick brown fox jumped over the lazy dog.";
nsACString *aCString;
rv = stringService->CreateACString(in,
&aCString);
if (NS_FAILED(rv)) {
printf("cound not create nsACString.\n");
return -1;
}
char in1[] = "The quick brown fox jumped over the lazy dog.";
nsACString *aCString;
rv = stringService->CreateACString(in1,
sizeof in1,
&aCString);
if (NS_FAILED(rv)) {
printf("cound not create nsACString.\n");
return -1;
}
char* out1;
rv = stringService->GetString(*aCString, &out1);
if (NS_FAILED(rv)) {
printf("Could not obtain string from nsACString.\n");
return -1;
char* out1;
rv = stringService->GetString(*aCString, &out1);
if (NS_FAILED(rv)) {
printf("Could not obtain string from nsACString.\n");
return -1;
}
}
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return 0;