mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
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:
parent
eba1c08907
commit
1d187936dc
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user